Because I am curious, there are some promotions and other mail, after the sender, there is a .... Hair generation.
Therefore, some data were found to verify the implementation.
Let's take a look at it and realize the ideal of generation.
Of course, this kind of, is the use of the sending mailbox server to send, (below you code, notes)
The code is as follows:
//instantiate two necessaryMailMessage mail =NewMailMessage (); SmtpClient SMTP=NewSmtpClient (); //send e-mail addressMail. from =NewMailAddress ("[email protected]"); //here is the e-mail, the following Mailbox server address, but also fill out the server address of the sending mailboxMail. Sender =NewMailAddress ("[email protected]"); //recipients (can be mass)Mail. To.add (NewMailAddress ("[email protected]")); //whether to send in HTML formatMail. isbodyhtml =true; //encoding format for themesMail. Subjectencoding =Encoding.UTF8; //the title of the messageMail. Subject ="test the title of a issued piece"; //encoding format for contentMail. Bodyencoding =Encoding.UTF8; //priority of the messageMail. Priority =Mailpriority.normal; //send content, we feel free to fill in some. Mail. Body =@"Gets the user IP that opens the message, and the image is automatically generated by the server:"; //the recipient can be inside the messageMail. Headers.add ("disposition-notification-to","Receipt Information"); //the server address of the outgoing mailboxSmtp. Host ="smtp.163.com"; Smtp. Deliverymethod=smtpdeliverymethod.network; Smtp. Timeout=1000000; //is SSL encryptedSmtp. Enablessl =true; //set the port, if not set, the default port isSmtp. Port = -; Smtp. useDefaultCredentials=false; //verifying the sender's credentialsSmtp. Credentials =NewSystem.Net.NetworkCredential ("[email protected]","xxxx"); Try { //Send mailSMTP. Send (mail); Console.WriteLine ("sent successfully"); } Catch(Exception e) {Console.WriteLine ("Send failed:"+e.message); }
Of course, some of the above mailbox information, I changed some of the province, which sister, send me an e-mail Hahahahahahahahah
Let's look at the effect of the final implementation.
In this case, a generation of e-mail, successfully completed.
Note: The key to the code is
Mail. Sender = new MailAddress ("[email protected]");
The server address of the outgoing mailbox
Smtp. Host = "smtp.163.com";
C # implements Mail generation