ABP 163 send mail as SMTP

. 1    ///  <Summary> 
2          /// transmission
 . 3          ///  </ Summary> 
. 4          ///  <param name = "the Subject"> message header </ param> 
. 5          ///  <param name = "Body"> message body </ param> 
. 6          ///  <param name = "mailTo"> receiving mailbox </ param> 
. 7          ///  <param name = "IsBodyHtml"> whether HTML format </ param> 
. 8          ///  <Returns > </ Returns> 
. 9          Private  BOOL the Send ( String the Subject, String Body,string mailTo, bool= IsBodyHtml to false )
 10          {
 . 11  
12 is              String smtpServer = " smtp.163.com " ; // the SMTP server 
13 is              String mailFrom = " [email protected] " ; // login user name, E-mail 
14              String the userPassword = " XXXX " ; // Note that the authorization code is not password 
15              SmtpClient SmtpClient = new new SmtpClient ();
 16              smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; // specify how you send email
. 17              smtpClient.Host = smtpServer; // specified SMTP server 
18 is              smtpClient.Credentials = new new System.Net.NetworkCredential (mailFrom, the userPassword); // user name and password
 19                                                                                                // Send mail setting        
20 is              the MailMessage MailMessage = new new the MailMessage (mailFrom, mailTo ); // sender and recipient 
21              mailMessage.Subject = Subject; // theme 
22              mailMessage.Body = body; // content 
23              mailMessage.BodyEncoding = Encoding.UTF8; // text encoding of 
24             = IsBodyHtml mailMessage.IsBodyHtml; // set to HTML 
25              mailMessage.Priority = MailPriority.Low; // priority 
26 is  
27              the try 
28              {
 29                  smtpClient.Send (MailMessage); // send a message 
30                  return  to true ;
 31 is              }
 32              the catch (SmtpException EX)
 33 is              {
 34 is                  return  to false ;
 35              }
 36          }

 

Guess you like

Origin www.cnblogs.com/LmuQuan/p/11233582.html