I have tried different things like adding more than one email separated
with a semi-colon and also replicating the <errorMail> tag in the
web.config. So far nothing has worked. I might be overlooking
something obvious.
mail.To.Add(new MailAddress(recipient));
To instead read:
foreach (string address in recipient.Split(";"))
mail.To.Add(new MailAddress(address));
Hope this helps.
- Atif
For future reference I had to use this code.
foreach (string address in recipient.Split(new Char[] {';'}))
mail.To.Add(new MailAddress(address));
Minor change from what was suggested. Split wanted a character array
instead of a string.
I should also note that if you use a multiple recipient list you need
to use the from attribute on the <errorMail> tag. If the from isn't
there it uses the to attribute as the default. However, trying to use
something like ma...@domain.com;ma...@domain.com as the sender address
will cause an error. A simple code fix would be to check for multiple
recipients and if more than one set the sender to the first one. This
is of course if the from attribute is missing. I am going to just add
the from attribute but I thought I would pass that potential situation
along.
Ah yes well that's the problem for not having code IntelliSense in your
mail editor. :-P Since String.Split supports variable-arguments syntax
sugar, you should be able to get away with just changing the double
quotes to single quotes, as in:
foreach (string address in recipient.Split(';'))
mail.To.Add(new MailAddress(address));
Good catch about the "from" attribute.
- Atif
-----Original Message-----
From: el...@googlegroups.com [mailto:el...@googlegroups.com] On Behalf
Of ericday
Sent: Monday, August 14, 2006 5:48 PM
To: ELMAH
Subject: Re: Mail Errors to Multiple Recipients
Thanks for the tip.
String.Split(";"C)
Since VB uses single quotes for comments, a character uses double quotes
but is immediately followed by the character C to denote that it's a
single character (of type System.Char) instead of an entire string
(System.String). May be you're not compiling in Option Strict mode so VB
is making an implicit conversion. It should pass however at runtime.
-----Original Message-----
From: el...@googlegroups.com [mailto:el...@googlegroups.com] On Behalf
Of ericday
Sent: Tuesday, August 15, 2006 5:23 AM
To: ELMAH
Subject: Re: Mail Errors to Multiple Recipients