C # uses mail class to send QQ mail

Source: Internet
Author: User
Tags mailmessage
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);
 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.