misho
misho

Reputation: 1195

How can I add multiple email addresses in Outlook field "To" via C#?

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]

Upvotes: 0

Views: 956

Answers (2)

ChrisF
ChrisF

Reputation: 137188

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 + "; ");

Upvotes: 1

Neil Knight
Neil Knight

Reputation: 48587

newMail.To.Add(new MailAddress(to));

Upvotes: 1

Related Questions