C # using Smtp, send messages through qqmail

public static void SendEMail(string senderEmail, string senderAuthCode, string smtpHost, int smtpPort,
string receiverEmail, string subject, string body)
{
MailMessage msg = new MailMessage();
msg.To.Add(receiverEmail);
//msg.To.Add([email protected]);
//msg.CC.Add("[email protected]");可以抄送给多人

= the MailAddress new new msg.From (SENDEREMAIL);
msg.Subject = Subject;
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.Body = body;
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = false;
msg.Priority = MailPriority.High;
SmtpClient Client = new new SmtpClient ();
client.Credentials = new new NetworkCredential (of SENDEREMAIL, senderAuthCode); // senderAuthCode not qq-mail password, need to qq-mail settings> accounts> smtp. .., authorization code
client.Port = smtpPort; // QqMail: 587 ( NOTE: 465 is invalid)
client.Host = smtpHost; // "smtp.qq.com";
client.EnableSsl = to true; // through ssl encryption
client.Send (MSG);
}

Reproduced in: https: //www.cnblogs.com/erentec/p/11066226.html

Guess you like

Origin blog.csdn.net/weixin_34177064/article/details/93691122