QQ邮箱发送邮件

原文来自:http://blog.csdn.net/mojocube/article/details/51517171

System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
try
{
mail.To = "接收的邮箱";
mail.From = "发送的邮箱";
mail.Subject = "这是主题";
mail.BodyFormat = System.Web.Mail.MailFormat.Html;
mail.Body = "这是内容";

mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //身份验证
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", mail.From); //邮箱登录账号,这里跟前面的发送账号一样就行
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "!!!!!!!"); //这个密码要注意:如果是一般账号,要用授权码;企业账号用登录密码
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 465);//端口
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");//SSL加密
System.Web.Mail.SmtpMail.SmtpServer = "smtp.qq.com"; //企业账号用smtp.exmail.qq.com
System.Web.Mail.SmtpMail.Send(mail);

//邮件发送成功
}
catch (Exception ex)
{
//失败,错误信息:ex.Message;
}

作者:D调灬仔
出处:https://www.cnblogs.com/chj929555796/
您的推荐是我最大的动力,如果觉得这篇文章对你有帮助的话,请点个“推荐”哦,博主在此感谢!
原文地址:https://www.cnblogs.com/chj929555796/p/8205243.html