Using system. collections;
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. net. mail;
Using system. net;
Using system. text;
Public partial class sendmailtest: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
Sendmail_1 ();
}
Private void sendmail_1 ()
{
Mailmessage Mm = new message (New mailaddress ("SendMail@Dimon.com", "displayname", encoding. getencoding ("gb2312"), new mailaddress ("RecieveMail@Dimon.com", "displayname", encoding. getencoding ("gb2312 ")));
Smtpclient SMTP = new smtpclient ("smtp.dimon.com ");
Networkcredential NC = new networkcredential ("yourname", "yourpwd ");
Mm. Subject = "subject ";
Mm. Body = "body ";
Mm. bodyencoding = encoding. getencoding ("gb2312 ");
Mm. subjectencoding = encoding. getencoding ("gb2312 ");
Mm. isbodyhtml = true;
SMTP. Credentials = NC;
Try
{
SMTP. Send (mm );
Response. Write ("OK ");
}
Catch (smtpfailedrecipientexception ex) // catch whether the mailbox is available or not
{
Response. Write (ex. Message. tostring ());
Response. Write ("<br> ");
Response. Write ("<br> ");
Response. Write ("false ");
}
}
Tested, easy to use !!!