using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Web.Mail;namespace LookeCS1 { /// <summary> /// Summary description for test1. /// </summary> public class test1 : System.Web.UI.Page { protected System.Web.UI.WebControls.TextBox mailfrom; protected System.Web.UI.WebControls.TextBox mailto; protected System.Web.UI.WebControls.TextBox mailsubject; protected System.Web.UI.WebControls.TextBox mailbody; protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e) { } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Button1.Click += new System.EventHandler(this.Button1_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void Button1_Click(object sender, System.EventArgs e) { SmtpMail.Send(mailfrom.Text,mailto.Text,mailsubject.Text,mailbody.Text); } } }
你得在IIS中安装smtpmail 声明; using System.Web.Mail; 注册成功的那一步加 string subject="你好";string Mailbody="首先感谢您注册您的用户名是"+TxtUserName.Text+"如果您有问题,请与我们联系";
————————————————————————————————————————
在你的程序邮件中你可以使用任何邮件地址作为FROM参数的属性,这个属性写在邮件协议中,仅仅是个普通符号,协议以及服务器都不会去实际验证它。当你收到一封邮件的时候,你绝对不能根据FROM来判断这封邮件的真实来源。其实还是老问题:发送邮件不是什么“邮件系统”做的,而只是一个SMTP发送小程序作的,实际上你使用TELNET手动写上几条命令就能把邮件发送出去,其中的FROM你随便填写,而TELNET仅仅是跟任何字符终端联网调试的一个通用的小程序。你使用哪个SMTP完全是自己决定。在安装IIS的时候如果同时安全SMTP服务器,那么你就可以让自己的服务器发送邮件。如果你没有安装SMTP服务,就可以使用任何别人的SMTP服务器(地址)发送。
可以直接复制 粘贴
http;//blog.hexun.comn/niedewang
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;namespace LookeCS1
{
/// <summary>
/// Summary description for test1.
/// </summary>
public class test1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox mailfrom;
protected System.Web.UI.WebControls.TextBox mailto;
protected System.Web.UI.WebControls.TextBox mailsubject;
protected System.Web.UI.WebControls.TextBox mailbody;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{ } #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
SmtpMail.Send(mailfrom.Text,mailto.Text,mailsubject.Text,mailbody.Text);
}
}
}
声明;
using System.Web.Mail;
注册成功的那一步加
string subject="你好";string Mailbody="首先感谢您注册您的用户名是"+TxtUserName.Text+"如果您有问题,请与我们联系";