Multiple address in MailAddress constructor

Vetrivel mp picture Vetrivel mp · Mar 16, 2012 · Viewed 34.2k times · Source

i was trying to add multiple to address like this.

MailAddress mailAddressTo = new MailAddress("[email protected];[email protected]","Vetrivelmp");

but throws error like

An invalid character was found in the mail header: ';'

Answer

Massimiliano Peluso picture Massimiliano Peluso · Mar 16, 2012

You cannot use the MailAddress constructor for specifying multiple receipts, but you can to use the MailMessage object as showed below.

Using the MailMessage (not MailAddress) constructor:

var msg = new MailMessage("[email protected]", "[email protected], [email protected]");

another way is:

MailMessage mail = new MailMessage();
mail.To.Add("[email protected],[email protected],[email protected]");

another way is:

MailMessage msg = new MailMessage();
msg.To.Add("[email protected]");
msg.To.Add("[email protected]");
msg.To.Add("[email protected]");
msg.To.Add("[email protected]");