<summary>
Send mail
</summary>
<param name= "MailTo" > Mailbox to send </param>
<param name= "Mailsubject" > Email topics </param>
<param name= "mailcontent" > Mailbox content </param>
public static bool Sendemails (string mailTo, String mailsubject, String mailcontent)
{
// set the sender's mail information, such as using NetEase's SMTP
stringSmtpServer ="smtp.qq.com";//Enterprise account with smtp.exmail.qq.com stringMailfrom ="your QQ number is @qq.com";//Login User Name stringUserPassword ="ECGWDUIRLHVRBEHB";//This password to note: If it is a general account, to use the authorization Code; Enterprise account with login password//Mail Service SettingsSmtpClient SmtpClient =NewSmtpClient (); Smtpclient.deliverymethod= Smtpdeliverymethod.network;//specify how e-mail is sentSmtpclient.host = SmtpServer;//Specify the SMTP serverSmtpclient.credentials =NewSystem.Net.NetworkCredential (Mailfrom, UserPassword);//user name and password//Send mail SettingsMailAddress Mafrom =NewMailAddress (Mailfrom,"Test Mailbox");//Change Sender titleMailAddress MaTo =Newmailaddress (MailTo); MailMessage MailMessage=NewMailMessage (Mafrom, maTo); //MailMessage mailmessage = new MailMessage (Mailfrom, mailTo);//Sender and Recipient//MailMessage.CC.Add (mailtos);Mailmessage.subject = Mailsubject;//ThemeMailmessage.body = mailcontent;//contentmailmessage.bodyencoding = Encoding.UTF8;//Body Codemailmessage.isbodyhtml =true;//set to HTML formatmailmessage.priority = Mailpriority.high;//Priority Level string[] File = {"Files path" }; //Add a message attachment to send multiple files foreach(varFileNameinchfile) {MAILMESSAGE.ATTACHMENTS.ADD (NewAttachment (filename, MediaTypeNames.Application.Octet)); } Try{smtpclient.send (mailmessage);//Send mail return true; } Catch(Smtpexception ex) {return false; }
}
How to open the authorization code of QQ mailbox
Https://jingyan.baidu.com/article/fedf0737af2b4035ac8977ea.html
. NET using QQ mailbox to send mail