Currently, most emails require stmp authentication,
. Net
System. Web. util
System. Web. Mail
No.
I write this articleArticleI hope it will help you with your development projects.
Find a component namedJmail
You can find it online, download it, and install it.
Reference jmail. DLL to the Project
Figure 1:
Private void button#click (Object sender, system. eventargs E)
{
Jmail. Message jmail = new jmail. Message ();
Datetime T = datetime. now;
String subject = "from email. Net ";
String body = "12:12:12 ";
String fromemail = "ljt21@163.com ";
String toemail = "xiao-maolover@163.com ";
// Silent attribute: If set to true, jmail will not throw an exception error. jmail. Send () will return true or false Based on the operation results
Jmail. Silent = true;
// Logs created by jmail, provided that the loging attribute is set to true
Jmail. Logging = true;
// Character Set, default: "US-ASCII"
Jmail. charset = "gb2312 ";
// Contentype of a letter. The default value is "text/plain"): If you send an email in HTML format, change it to "text/html.
Jmail. contenttype = "text/html ";
// Add recipient
Jmail. addrecipient (toemail ,"","");
Jmail. From = fromemail;
// Sender's email user name
Jmail. mailserverusername = "ljt21 ";
// Sender's email password
Jmail. mailserverpassword = "****";
// Set the mail title
Jmail. Subject = subject;
// Add attachments to the email. (If there are multiple attachments, you can add jmail. addattachment ("C: \ test.jpg", true, null. [Note]: add an attachment to delete the above jmail. contenttype = "text/html. Otherwise, garbled characters will appear in the email.
Jmail. addattachment ("C: \ test.jpg", true, null );
// Email content
Jmail. Body = body + T. tostring ();
// Jmail sending Method
Jmail. Send ("smtp.163.com", false );
Jmail. Close ();
}
So OK ..!