JSideris
JSideris

Reputation: 5261

How can I send emails to multiple recipients using a MailDefinition

I'm creating a new mail definition using the CreateMailMessage function of a MailDefinition. One of the required parameters is recipients. The documentation for this function states that recipients is to be a comma-separated list of recipients, however when I try to send a message to multiple users I am getting the following error:

An invalid character was found in the mail header: ','...

So it seems like this function is not working as intended. Normally I would add all the recipients to the mail message itself, but unfortunately the recipients parameter is required and cannot be left blank. Any ideas?

Upvotes: 1

Views: 1326

Answers (1)

JSideris
JSideris

Reputation: 5261

I got it working but unfortunately its more of a hack than anything.

I take one email address from the "to" field and set it as the recipient in CreateMailMessage, which returns a MailMessage instance.

I take the produced MailMessage and add all the email addresses in my MailAddressCollection by iterating through the construct. I also do this for all CC'd users.

Upvotes: 1

Related Questions