I have multiple email recipients stored in SQL Server. When I click send in the webpage it should send email to all recipients. I have separated emails using ;
.
Following is the single recipient code.
MailMessage Msg = new MailMessage();
MailAddress fromMail = new MailAddress(fromEmail);
Msg.From = fromMail;
Msg.To.Add(new MailAddress(toEmail));
if (ccEmail != "" && bccEmail != "")
{
Msg.CC.Add(new MailAddress(ccEmail));
Msg.Bcc.Add(new MailAddress(bccEmail));
}
SmtpClient a = new SmtpClient("smtp server name");
a.Send(Msg);
sreader.Dispose();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…