Home > ASP.Net > Send Email to Multiple User

Send Email to Multiple User


Hi

try this method example to send email to multiple user using Gmail account

public Boolean sendemail(String strTo, string strFrom, string strSubject, string strBody, bool IsBodyHTML)
{
Array arrToArray;
char[] splitter = { ';' };
arrToArray = strTo.Split(splitter);
MailMessage mm = new MailMessage();
mm.From = new MailAddress(strFrom);
mm.Subject = strSubject;
mm.Body = strBody;
mm.IsBodyHtml = IsBodyHTML;
foreach (string s in arrToArray)
{
mm.To.Add(new MailAddress(s));
}
SmtpClientsmtp = new SmtpClient();
try
{
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
NetworkCred.UserName = Your Gmail Email;
NetworkCred.Password = Your Gmail password;
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 465;
smtp.Send(mm);
mm = null;
smtp = null;
return true;
}
catch (Exception ex)
{
smtp = null;
return false;
}
}

this method return true (mean mail sent) or false (mean not sent)

hope it helps

Best Regards

Advertisements
Categories: ASP.Net Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: