Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. Collections. Generic;
Using system. net. mail;
Using system. net;
Using system. IO;
Namespace kuaican. Web
{
/// <Summary>
/// Class for sending e-mail. It can be sent (recommended) after testing)
/// </Summary>
Public class sendmail
{
Public String sendemail (string toaddr, String title, string content)
{
Mailmessage MSG = new mailmessage ();
MSG. to. Add (toaddr );
MSG. to. Add ("xxxxxxxxxx@163.com ");
MSG. CC. Add ("xxxxxxxxxx@163.com ");
MSG. From = new mailaddress ("xxxxxxxxxx@163.com", "automation Mercer", system. Text. encoding. utf8 );
MSG. Subject = title;
MSG. subjectencoding = system. Text. encoding. utf8;
MSG. Body = content;
MSG. bodyencoding = system. Text. encoding. utf8;
MSG. isbodyhtml = false;
MSG. Priority = mailpriority. normal;
Smtpclient client = new smtpclient ();
Client. Credentials = new networkcredential ("xxxxxxxxxx@163.com", "password ");
Client. Port = 25; // 587,465,995
Client. Host = "smtp.163.com ";
// Client. enablessl = true;
// Object userstate = MSG;
Try
{
Client. Send (MSG );
Return "sucess ";
}
Catch (smtpexception ex)
{
Return ex. Message + "sendemail error ";
}
}
}
}