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

 3509浏览
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);
}
流行热度:超过3509次围观
生产日期:2014-05-10 13:04:41
上次围观:2016-09-18 12:37:32
转载时必须以链接形式注明原始出处及本声明。