Sending Multiple mail in a queue in asp.net:
string strTo = txtTo.Text;
for (int i = 0; i < strTo.Split(',').Length;i++ )
{
string strMailId = strTo.Split(',')[i];
try
{
MailMessage msg = new MailMessage();
msg.From = txtFrom;
msg.To=txtTo;
msg.Subject = txtSubject.Text;
msg.IsBodyHtml = true;
msg.Body = txtMail.Text;
msg.Priority = MailPriority.High;
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.gmail.com", 25);
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("xxx@gmail.com", "xxx"); //Email and Password
client.EnableSsl = true;
client.Send(msg );
ScriptManager.RegisterStartupScript(btnSend, typeof(Page), "Confirm", "alert('Your enquiry sent successfully!');formReset();", true);
}
catch (Exception Ex)
{
ScriptManager.RegisterStartupScript(btnSend, typeof(Page), "Error:", "alert('Oops! Some error occoured.')", true);
}
}
string strTo = txtTo.Text;
for (int i = 0; i < strTo.Split(',').Length;i++ )
{
string strMailId = strTo.Split(',')[i];
try
{
MailMessage msg = new MailMessage();
msg.From = txtFrom;
msg.To=txtTo;
msg.Subject = txtSubject.Text;
msg.IsBodyHtml = true;
msg.Body = txtMail.Text;
msg.Priority = MailPriority.High;
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.gmail.com", 25);
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("xxx@gmail.com", "xxx"); //Email and Password
client.EnableSsl = true;
client.Send(msg );
ScriptManager.RegisterStartupScript(btnSend, typeof(Page), "Confirm", "alert('Your enquiry sent successfully!');formReset();", true);
}
catch (Exception Ex)
{
ScriptManager.RegisterStartupScript(btnSend, typeof(Page), "Error:", "alert('Oops! Some error occoured.')", true);
}
}