2004.11.5 利用 System.Web.Mail 发送邮件

类别:软件工程 点击:0 评论:0 推荐:
母亲明天就要回老家了,祝她一路顺风!

在别人的blog上看到的一段代码。引自:http://blog.joycode.com/ghj/archive/2004/02/17/13197.aspx
下面代码在使用前需要引用System.Web.dll
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "[email protected]";
mail.From = "[email protected]";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here

SmtpMail.SmtpServer = "mail.mycompany.com"; //your real server goes here
SmtpMail.Send( mail );
}

本文地址:http://com.8s8s.com/it/it34336.htm