Bulk Email Sending with Specific File
Bulk Email sending
protected void Button7_Click(object sender, EventArgs e)
{
foreach (ListItem item in this.ListBox2.Items)
{
if (item.Selected)
{
MailMessage mail = new MailMessage();
mail.To.Add(new MailAddress(item.Text));
mail.From = new MailAddress("email");
mail.Subject = "Happy Ganesh 2014";
mail.Body = TextBox4.Text;
mail.Attachments.Add(new Attachment(FileUpload1.FileContent,
System.IO.Path.GetFileName(FileUpload1.FileName)));
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential("email", "pass");
smtp.EnableSsl = true;
smtp.Send(mail);
}
}
}