C # mailing method [way] webMail

In the last post C # mailing method [way] webMail introduced Webmail mailing way, now under way to introduce C #, using NetMail send mail,

Test code is as follows:

 /// <Summary>
    /// test mode by the NetMail
    /// </ Summary>
    Private void TestSend ()
    {
        System.Net.Mail.MailMessage new new System.Net.Mail.MailMessage mm = ();
        // Write address of
        mm.To.Add (new new System.Net.Mail.MailAddress ( "[email protected]", "the Name"));
        // sender address
        mm.From = new System.Net.Mail.MailAddress ( "[email protected]");
        // this may not specify
        //mm.Sender new new System.Net.Mail.MailAddress = ( "[email protected]", "the SenderName") ;,

        mm.Subject = "this In Email the Test IS ";
        mm.Body =" <H3> This IS Testing By the SMTP Mail the Send Me </ H3> ";
        mm.IsBodyHtml = to true;
        mm.Priority = System.Net.Mail.MailPriority.High; // send a message priority setting
        SmtCliend = new new System.Net.Mail.SmtpClient System.Net.Mail.SmtpClient ();
        // specify the mail server
        smtCliend.Host = "smtp.sina.com";
        the port number // smtp mail server  
        smtCliend.Port = 25 ;   
        // set the sender's mailbox user name and address, the mail server generally requires the use of a public offer, or sending does not succeed
       smtCliend.Credentials = new new NetworkCredential ( "xxxxxxx", "xxxxxxx");

        // specified e-mail sending mode
        smtCliend = System.Net.Mail.SmtpDeliveryMethod.Network .DeliveryMethod;
        the try
        {
            smtCliend.Send (mm);
        }
        the catch (System.Net.Mail.SmtpException EX)
        {
            Response.Write (ex.Message);
        }
        the catch (Exception EX)
        {
            Response.Write(ex.Message);
        }
    }



Reproduced in: https: //www.cnblogs.com/kevinGao/archive/2011/12/23/3589981.html

Guess you like

Origin blog.csdn.net/weixin_33704591/article/details/93052976