Use ASP.net to send mail components from the mail, support 126,163,GMAIL,QQ and other mailboxes __.net

Source: Internet
Author: User
    #region Mail to send///<summary>///send mail support HTML format first to quote System.Net.Mail; </summary>///<param name= "Mailfrom" > Sender email such as demo@126.com</param>///<param name= "Mai Lserver "> mail server such as mail.126.com</param>///<param name=" mailusername "> login username such as Demo@126.com</param >///<param name= "MailPassword" > Login password such as 123456</param>///<param name= "mailto" > Recipient mailbox </para m>///<param name= "title" > Message title </param>///<param name= "MSG" > Message body </param>///< Returns> success true; Failed false</returns> public static bool Sendsmtpemail (string mailfrom, String mailserver, string mailusername, str
        ing MailPassword, string mailto, string title, String msg) {var client = new SmtpClient (); Client.
        Host = mailserver; Client.
        useDefaultCredentials = false; Client.
        Credentials = new System.Net.NetworkCredential (Mailusername, MailPassword); Client.
        Deliverymethod = Smtpdeliverymethod.network;
        System.Net.Mail.MailMessage message = new MailMessage (mailfrom, mailto); Message.
        Subject = title; Message.
        BODY = msg; Message.
        subjectencoding = System.Text.Encoding.UTF8; Message.
        bodyencoding = System.Text.Encoding.UTF8; Message.
        Isbodyhtml = true; Message.
        Priority = Mailpriority.high; Message.
        Isbodyhtml = true; try {client.
            Send (message);
        return true;
        catch {return false;  }} #endregion

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.