Email with multiple address
-
I want to send an email to multiple people and I want to store the addresses in the web.config file. Therefore my web.config has the following and my code looks like this. Some essential has been ommited
Dim message As New MailMessage() message.From = New MailAddress("site@homesolution.ltd.uk", "Homesolution Site") message.To.Add((ConfigurationManager.AppSettings("NotificationEmailAddresses")) message.Subject = "New Event Occurred"
For some reason this doesn't seem to work. The email never arrives and no error appears. How do I get this to work so I can send to multiples. Thanks -
I want to send an email to multiple people and I want to store the addresses in the web.config file. Therefore my web.config has the following and my code looks like this. Some essential has been ommited
Dim message As New MailMessage() message.From = New MailAddress("site@homesolution.ltd.uk", "Homesolution Site") message.To.Add((ConfigurationManager.AppSettings("NotificationEmailAddresses")) message.Subject = "New Event Occurred"
For some reason this doesn't seem to work. The email never arrives and no error appears. How do I get this to work so I can send to multiples. ThanksWhen I have done this before I sent a sepparate email to each person. Here is some C# code in .net 2.0 assuming you have a comma delimited list in your config file.
MailAddress to = null;
bool ret = false;
if (p_to.IndexOf(",") != -1)
{
string[] addrs = p_to.Split(',');
for (int i = 0; i < addrs.Length; i++)
{
to = new MailAddress(addrs[i]);
ret = SendEmail(to, null, null, p_subject, p_body);
if (!ret)
{
return ret;
}
}//for
return ret;
}
else
{
to = new MailAddress(p_to);
return SendEmail(to, null, null, p_subject, p_body);
}
<\pre>The SendEmail method just wraps the smtp sendmail function.
Hope that helps.
Ben