views:

31

answers:

2

Hi all,

Anybody know how can I add multiple email addresses in Outlook field "To" via C#?

foreach (var to in mailTo)
            newMail.To += to + "; ";

When I try do it how I described this above I receive next kind of string: [email protected]@[email protected]

+1  A: 
newMail.To.Add(new MailAddress(to));
Ardman
A: 

The += operator doesn't work how you are trying to use it.

a += b + c;

has no meaning. If you want to do it this way you'll have to add brackets around the right hand side:

newMail.To += (to + "; ");
ChrisF
Thanks a lot! Yeah!
misho