Sendmail
Public bool Sendmail (string SMTP, string t_port, string from, string PWD, string to, string subject, string bodytext, string displayname, bool SSL)
{
System. net. Mail. smtpclient client = new smtpclient ();
Client. Host = SMTP;
Client. usedefacrecredentials = true;
Client. Timeout = 135000;
Client. deliverymethod = smtpdeliverymethod. Network;
Client. Credentials = new system. net. networkcredential (from, PWD );
Client. deliverymethod = smtpdeliverymethod. Network;
Client. Port = convert. toint32 (t_port );
System. net. Mail. mailmessage message = new mailmessage (from, );
Message. From = new mailaddress (from, displayname );
Message. Subject = subject;
Message. Body = bodytext;
Message. isbodyhtml = true;
Message. bodyencoding = system. Text. encoding. utf8;
Client. enablessl = SSL;
Client. Credentials = new system. net. networkcredential (from, PWD );
RegEx Reg = new RegEx (@ "^ \ W + ([-+.] \ W +) * @ \ W + ([-.] \ W + )*\. \ W + ([-.] \ W +) * $ ");
Try
{
If (Reg. ismatch (from) & reg. ismatch ())
{
Client. Send (Message );
Return true;
}
Else
Return false;
}
Catch (exception ex)
{
Return false;
}
}