编程那点事编程那点事

专注编程入门及提高
探究程序员职业规划之道!

C#利用System.web.mail发送邮件

System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage(,2);
try
{
mail.To = "收件人邮箱";
mail.From = "发件人邮箱";
mail.Subject = "subject";
mail.BodyFormat = System.Web.Mail.MailFormat.Html;
mail.Body = "<font color='red'>body</font>";

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1",2); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "发件人邮箱",2); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "发件人邮箱密码",2); //set your password here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 465,2);//set port
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true",2);//set is ssl
System.Web.Mail.SmtpMail.SmtpServer = "smtp.qq.com";
System.Web.Mail.SmtpMail.Send(mail,2);
//return true;
}
catch (Exception ex)
{
ex.ToString(,2);
}
未经允许不得转载: 技术文章 » .NET编程 » C#利用System.web.mail发送邮件