first, set up QQ mailbox Open service
1. Open POP3/SMTP Service
Steps: Login QQ mailbox >> Setup >> account >> Open service >> Remember the Authorization code (this authorization code will be used in C # code), as shown in the following figure:
second, code implementation
1. Using System.Web.Mail.MailMessage, the code is as follows:
System.Web.Mail.MailMessage Mail = new System.Web.Mail.MailMessage (); Mail. to = "example@qq.com";//Accept-side mailbox mail. from = "example@qq.com";//Sender Mailbox mail. Subject = "RSVP Notification";//Message subject (title) mail. BodyFormat = system.web.mail.mailformat.html;//Right key content type Mail. BODY = Model.name + ' is ' + (model.willattend?? False)? "": "not" + "attending";//mail contents mail. Fields.Add ("Http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //authentication Mail . Fields.Add ("Http://schemas.microsoft.com/cdo/configuration/sendusername", mail. from); //e-Mail login account //This password to note: If it is a general account, to use the authorization code (that is, the first step we open QQ Mailbox service generated authorization code); Enterprise account with login password mail. Fields.Add ("Http://schemas.microsoft.com/cdo/configuration/sendpassword", "************"); Mail. Fields.Add ("Http://schemas.microsoft.com/cdo/configuration/smtpserverport", 465);//Port mail.
Fields.Add ("Http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");//ssl encryption System.Web.Mail.SmtpMail.SmtpServer = "smtp.qq.com";Enterprise account with smtp.exmail.qq.com System.Web.Mail.SmtpMail.Send (Mail);