WebMail.Send () throws FormatException

I am trying to send WebMail.Send() email to multiple email IDs. The MSDN library page clearly states that multiple email identifiers should be separated by a semicolon (;). However, when I try to send letters to multiple identifiers, I get a FormatException with a message that says "An invalid character was found in the mail header: ';' However, if I send mail to one receiver, the mail is delivered correctly.

So how to send mail to multiple recipients using WebMail.Send() ? Perhaps I am missing something very obvious.

Edit: Here is the code I'm using.

 string [] selectedUserIds = GetEmailIds(); string to = string.Join(";", selectedUserIds); WebMail.Send(to: to, subject: subject, body: message, cc: cc, filesToAttach: attachments, isBodyHtml:true); 
0
source share
2 answers

I think this is a documentation error. Separator works for,. This is the standard email address delimiter.

See the System.Net.Mail namespace: http://msdn.microsoft.com/en-us/library/14k9fb7t.aspx - see the last comment.

+1
source

System.Net.Mail related classes are used to separate addresses in the To, Cc, and Bcc fields. I suggest you change your code to look like this:

 string to = string.Join(",", selectedUserIds); 
0
source

Source: https://habr.com/ru/post/952755/


All Articles