C# 调用163发送邮件
作者:互联网
private void sendMail2VistorSSL(Model.LeaveMsg msg)
{
var url = Request.Url.AbsoluteUri;
var emailAcount = "anne@cXXX.com";
var emailPassword = "PenDsRXT3v";// "J17"; xia8gxh@163 "nqkqgff";//
var reciver = msg.Email;
var content =
"<p>Thank you for your attention to Jack sewing machine!</p>" +
"<p>We have received your message and we will contact with you as soon as possible!</p>" +
"<p>Thanks again!</p>" +
"<p>================================ you leave message =============================</p>" +
// "<p>" + txt_Name.Text.Trim() + ", from " + txt_Country.Text.Trim() + ".</p>" +
"<p>Left Message \"" + txt_Msg.Text.Trim() + "\" at </p>";
if (txt_Msg.Text.Trim().IndexOf("https") >= 0)
{
return;
}
content += Request.Url.AbsoluteUri;
System.Web.Mail.MailMessage mail= new System.Web.Mail.MailMessage();
//设置发件人,发件人需要与设置的邮件发送服务器的邮箱一致
mail.From = emailAcount;
//设置收件人,可添加多个,添加方法与下面的一样
mail.To = reciver;
//设置抄送人
mail.Cc = "xiaofei2008gxh@163.com;" + emailAcount;
//设置邮件标题
mail.Subject = "杰克官网访客留言信息";
//设置邮件内容
mail.Body = content;
mail.BodyFormat = System.Web.Mail.MailFormat.Html;
//message.BodyEncoding=System.Text.Encoding.GetEncoding( "gb2312 ");
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", emailPassword); //这个密码要注意:如果是一般账号,要用授权码;企业账号用登录密码
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.exmail.qq.com"; //企业账号用smtp.exmail.qq.com
System.Web.Mail.SmtpMail.Send(mail);
}
标签:Web,C#,Fields,cdo,System,mail,com,邮件,163 来源: https://blog.csdn.net/xiaofei2008gxh/article/details/122716503