//The SMTP (Simple Mail Transport Protocol) basic message Transfer Protocol. Providing the SmtpClient class (System.Net.Mail) in the. NET Frameword Class Library, she provides a lightweight way to send SMTP e-mail messages. The Bcc property in the SmtpClient class is a collection of recipients that specify the CC of this e-mail message, which means that multiple delivery addresses can be made for each message. The Attachmenty property is also a collection that you can use to add multiple attachments to a message. Other classes used in sending messages are mostly//1. The attachment class, which represents a file attachment, that allows text, streams, and files to be attached to an e-mail message. //2. The MailAddress class that represents the e-mail address. //3. The MailMessage class that represents the e-mail message. /// <summary> ///send e-mail/// </summary> /// <param name= "tomailaddress" >Recipient</param> /// <param name= "Body" >Message Content</param> /// <param name= "Subject" >Message Subject</param> /// <param name= "path" >Path to Attachment</param> Public voidSetemail (stringTomailaddress,stringBodystringSubjectstringpath) {SmtpClient mailclient=NewSmtpClient ("smtp.qq.com"); //mailclient.port = 465;Mailclient.enablessl =true; //Credentials Login SMTP server AuthenticationMailclient.credentials =NewNetworkCredential ("User name","Password"); MailMessage message=NewMailMessage (NewMailAddress ("[email protected]"),Newmailaddress (tomailaddress)); //message. Bcc.add (New MailAddress ("[email protected]"); //multiple recipients can be addedMessage. Body =body; Message. Subject=subject; if(Path! ="") {Attachment att=NewAttachment (@path); Message. Attachments.Add (ATT); } mailclient.send (message); }
C#qq e-Mail