// Add reference
Using system. net. mail;
Using system. text;
/// <Summary>
/// Send an email
/// </Summary>
/// <Param name = "fromemail"> sender's email </param>
/// <Param name = "PWD"> sender password </param>
/// <Param name = "toemail"> recipient email </param>
/// <Param name = "subject"> topic </param>
/// <Param name = "body"> content </param>
/// <Returns> </returns>
Public static bool send (string fromemail, string PWD, string toemail, string subject, string body)
{
Smtpclient client = new smtpclient ();
Client. Host = "SMTP." + fromemail. Remove (0, fromemail. indexof ("@") + 1 );
Client. usedefacrecredentials = false;
Client. Credentials = new system. net. networkcredential (fromemail, PWD );
Client. deliverymethod = smtpdeliverymethod. Network;
System. net. Mail. mailmessage message = new system. net. Mail. mailmessage (fromemail, toemail );
Message. Subject = "title:" + subject;
Message. Body = "content:" + body;
Message. bodyencoding = encoding. utf8;
Message. isbodyhtml = true;
Try
{
Client. Send (Message );
Return true;
}
Catch
{
Throw;
}
}
// Send
Protected void button#click (Object sender, eventargs E)
{
String STR = "Destination mailbox 1, destination mailbox 2, destination mailbox 3, destination mailbox 4 ";
String [] arrystr = Str. Split (',');
Foreach (string I in arrystr)
{
Send ("email", "password", I. tostring (), "test title", "content ");
}
// If (send ("source email", "password", "target email", "test title", "content ")! = True)
//{
// Response. Write ("failed ");
//}
// Else
//{
// Response. Write ("successful ");
//}
}