Public void Sendmail (string input)
{
Strhost = "smtp.163.com"; // SMTP server address
Straccount = "itjy1127"; // SMTP service account
Strpwd = "yujie1127"; // SMTP service Password
Strfrom = "itjy1127@163.com"; // the sender's email address
Console. writeline (Sendmail ("497928062@qq.com", "QQ", input )? "Success": "unsuccess ");
Console. Readline ();
}
/** // <Summary>
/// Send an email
/// </Summary>
/// <Param name = "to"> recipient's email address </param>
/// <Param name = "title"> email title </param>
/// <Param name = "content"> body content </param>
/// <Returns> </returns>
Public bool Sendmail (string to, 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); // user name and password
Mailmessage _ mailmessage = new mailmessage (strfrom, );
_ Mailmessage. Subject = title; // subject
_ Mailmessage. Body = content; // content
_ Mailmessage. bodyencoding = system. Text. encoding. utf8; // body Encoding
// _ Mailmessage. isbodyhtml = true; // set it to HTML Format
// _ Mailmessage. Priority = mailpriority. High; // priority
Try
{
_ Smtpclient. Send (_ mailmessage );
Return true;
}
Catch
{
Return false;
}
}