How to fix exception thrown when sending mail message to multiple recipients?

In the code snippet below, I'm getting a FormatException on 'this.Recipients'. More specifically, the message is "An invalid character was found in the mail header: ';'".

Recipients is a string of three email addresses separated by semicolons (the ';' character). The list of recipients is read from an app.config and the data is making it into the Recipients variable.

How can I be getting this error when multiple recipients should be separated by a semicolon? Any suggestions? As always, thanks for your help!

public bool Send()
{
    MailMessage mailMsg = 
       new MailMessage(this.Sender, this.Recipients, this.Subject, this.Message);

    SmtpClient smtpServer = new SmtpClient(SMTP);
    smtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;

Edit #1 - This says use a semicolon.

11
задан Uwe Keim 20 September 2012 в 10:31
поделиться