Let's just talk about the code.
Using system; using system. collections. generic; using system. LINQ; using system. text; using system. net. mail; namespace mailsender {class program {static string strhost = string. empty; static string straccount = string. empty; static string strpwd = string. empty; static string strfrom = string. empty; static void main (string [] ARGs) {strhost = "smtp.qq.com"; // The stmp server address straccount = "xxx@126.com"; // SMTP Service account strpwd = "123456"; // SMTP service password strfrom = "xxx@126.com"; // sender mail address console. writeline (Sendmail ("cnkker@qq.com", "this is a test mail", "this is the body content of a test mail ")? "Success": "unsuccess"); console. readline ();} /// <summary> /// send the email /// </Summary> /// <Param name = "to"> recipient's email address </param> /// <param name = "title"> email title </param> /// <Param name = "content"> body content </param> /// <returns> </returns >/// <author> jailu </author> /// <date> </date> static bool Sendmail (string, string title, string content) {smtpclient _ smtpclient = new smtpclient (); _ smtpclient. deliverymethod = smtpdeliverymethod. network; // specify the email sending method _ smtpclient. host = strhost; // specify the SMTP server _ smtpclient. credentials = new system. net. networkcredential (straccount, strpwd); // username and password mailmessage _ mailmessage = new mailmessage (strfrom, to); _ mailmessage. subject = title; // topic _ mailmessage. body = content; // content _ mailmessage. bodyencoding = system. text. encoding. utf8; // body encode _ mailmessage. isbodyhtml = true; // set it to HTML format _ mailmessage. priority = mailpriority. high; // priority try {_ smtpclient. send (_ mailmessage); Return true;} catch (exception ex) {return false ;}}}}
You know!