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 开发者_如何学Pythonhow I described this above I receive next kind of string: mail1@mail.commail2@mail.commail3@mail.com
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 + "; ");
newMail.To.Add(new MailAddress(to));
精彩评论