. NET using QQ mailbox to send mail

Source: Internet
Author: User

<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

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.