Started New Blog Services Ahmedabad Live News
Started another New Blog Services MoonEyes Cars

Wednesday, December 29, 2010

How can i send bulk email in asp.net

When we are planning to send bulk email it's really challenging that it's not going into spam or junk. I have created on example from where you send bulk email in asp.net

Here I used gmail smtp for sending bulk mail you may use your smtp if you wish. If you face any problem then please write comment I will update it.

protected void btn1_Click(object sender, EventArgs e)
{
ArrayList list_emails = new ArrayList();

SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.Host = "smtp.gmail.com";
client.Port = 587;

// setup Smtp authentication
System.Net.NetworkCredential credentials =
new System.Net.NetworkCredential("your_mail_account@gmail.com", "password");
client.UseDefaultCredentials = false;
client.Credentials = credentials;



string[] listmails = .Split(';');
foreach (string email_to in listmails)
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress("your_gmail_account@gmail.com");
msg.To.Add(new MailAddress(email_to));
msg.ReplyTo= (new MailAddress("bhadreshpanchal@cyberdesign.co.in"));
msg.Subject = "This is a test Email subject";
msg.IsBodyHtml = true;
msg.Body = string.Format("Test HTML Email123*****");

try
{
client.Send(msg);
Response.Write("Your message has been successfully sent.");
}
catch (Exception ex)
{
Response.Write("Your message has been successfully sent.");
Response.Write("Error occured while sending your message." + ex.Message);
}
}
}

No comments: