views:

412

answers:

1

I've got a method that basically has a "SendEmail" method (it will later be used by WCF service)

It has params like, Subject, Body, etc... and a string[] of Recipients. What I do, is create a MailMessage based on the parameters, then send it using smtp - I know the MailMessage has a To MailAddressCollection, but if I add each address to that, the message is CC'd to each and every person in the collection.

What I want to do is send it to them seperateley.

Is there any way of doing this, other than creating a seperate mail message for each item in the Recipient array, and sending it that way? I don't want to just BCC it to them either... as far as i know that's still recorded in the headers of the mail, and it's not particularly elegant.

+1  A: 

I think in this particular scenario you are restricted to creating a separate MailMessage object.

James
I agree, but you don't necessarily need to create a new object, just loop through the recipients array and change the TO address of the MailMessage object and then resend within the loop until you reach the last recipient.
ryanulit
@ryanulit, yeah even better.
James
how can i change the TO address..?It's a collection - I can to a To.Clear() and then To.Add("[email protected]") or something similar...
alex
@alex yes you would have to clear the list and add the new recipient
James
The only thing to keep in mind with this approach is that if you do have people CC'ed, they will get the email sent to them each time you send the email to a specific person.
Dan Appleyard