1. Tools and resources used: VS2012 provides smtpclient class (System.NET.Mail) in the. NET Frameword class Library
2. Operation
3, the specific code implementation
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingSystem.Net.Mail;usingSystem.Net.Mime;usingSystem.Net;usingSystem.IO;namespaceIntelligent Monitoring based on human face recognition { Public Partial classContact Us: Form { PublicContact Us () {InitializeComponent (); } Private voidYes_click (Objectsender, EventArgs e) { if(Usertext. Text = ="") {MessageBox.Show ("you don't have to enter any content! "); }Else Try { //determine the SMTP server address. Instantiate an SMTP clientSystem.Net.Mail.SmtpClient client =NewSystem.Net.Mail.SmtpClient ("smtp.qq.com", -);//pop.exmail.qq.com//smtp.qq.comClient. Enablessl =true;//specify smtpclient to use Secure Sockets Layer (SSL) encrypted connections//generate a Send address stringStrfrom ="[email protected]"; //constructs a sender address objectMailAddress from=NewMailAddress (Strfrom,"Providence", Encoding.UTF8); //constructs a recipient address objectMailAddress to =NewMailAddress ("[email protected]","Fate", Encoding.UTF8); //construct a Message object for an emailMailMessage message =NewMailMessage ( from, to); //add message subject and contentMessage. Subject ="Subject: User Comments" ; Message. Subjectencoding=Encoding.UTF8; Message. Body="content: Test messages"+ Usertext. Text;//The content that is sent when the user enters the textMessage. Bodyencoding =Encoding.UTF8; //set information for a messageClient. Deliverymethod =smtpdeliverymethod.network; Message. Bodyencoding=System.Text.Encoding.UTF8; Message. Isbodyhtml=true; //set the user name and password. Client. useDefaultCredentials =false; stringUsername ="227*******";//your e-mail account stringpasswd ="ESSC*********HC";//your authorization code, your password cannot login, the authorization code for a serial number such as esscncukoftqe**** application address https://mail.qq.com///User Login InformationNetworkCredential mycredentials =Newnetworkcredential (username, passwd); Client. Credentials=mycredentials; //Send mailclient. Send (message); MessageBox.Show ("Mail sent successfully, thank you for your support! "); } Catch{MessageBox.Show ("message failed to send"); } } }}
4, simple send the function of the mail to realize! Please give us a lot of advice!!! Thank you!!!!
5. Acknowledgement: Thanks to the vast number of Bo friends have selfless dedication!
C # Mail sending