日期:2014-05-17  浏览次数:20893 次

我有一个发邮件的页aspx,想转成asp的谁帮忙转一下,代码不多,比较简单,谢谢!急急急!
文件一(Default.aspx) :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title></title>
</head>
<body>  
<form id="form1" runat="server">  
<div> 发送人:<asp:TextBox ID="txtFrom" runat="server"></asp:TextBox> <br />  
收件人:<asp:TextBox ID="txtTo" runat="server"></asp:TextBox> <br />  
主题:<asp:TextBox ID="txtTheme" runat="server"></asp:TextBox> <br />  
附件:<asp:FileUpload ID="fpAttachment" runat="server" /> <br />  
内容:<asp:TextBox ID="txtContent" runat="server" Rows="20" TextMode="MultiLine" Width="300px"></asp:TextBox> <br />  
<asp:Button ID="Button1" runat="server" Text="发送" onclick="Button1_Click" />  
</div> </form>
</body>
</html>


文件二(Default.aspx.cs):
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;

public partial class _Default : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {

  }
  protected void Button1_Click(object sender, EventArgs e)
  {
  //测试通过,能发送带有附件的邮件  
  string from = txtFrom.Text.Trim(); //发件人  
  string to = txtTo.Text.Trim();//收件人  
  string theme = txtTheme.Text.Trim();//主题  
  //string file = fpAttachment.FileName;//附件文件名  
  string file = fpAttachment.PostedFile.FileName;//附件文件路径(包含文件名)  
  string content = txtContent.Text; //邮件内容  
  MailMessage messge = new MailMessage(from, to); //邮件消息实例  
  messge.Body = content;
  messge.Subject = theme;
  messge.IsBodyHtml = true;
  messge.Priority = MailPriority.High;//邮件优先级别  
  messge.Attachments.Add(new Attachment(file));
  SmtpClient client = new SmtpClient(); //Smtp协议  
  client.Host = "smtp.163.com"; //发送人的Smtp主机名称或IP地址,实例为163邮箱的Smtp地址  
  client.Credentials = new NetworkCredential("xuefei@163.com", "123456");//验证发件人的身份凭据  
  client.Send(messge);
  messge.Attachments.Dispose(); 
  }
}

------解决方案--------------------
http://home.51.com/yanzhan18/diary/item/10044106.html
------解决方案--------------------
有asp版的 发邮件代码 网上一搜就有了