Question

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.

Was it helpful?

Solution

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

OTHER TIPS

may be you can use something like this:

MailMessage msg= new MailMessage();
msg.Subject = *your subject text*;
msg.From = new MailAddress(*your address*, *your title*;);
msg.Body = *your body text*;;

foreach (DataRow row in dsRecipients .Tables[0].Rows)
{
    foreach (DataColumn col in dsRecipients .Tables[0].Columns)
    {
        msg.To.Clear();
        msg.To.Add(new MailAddress((string)row[col]));
        server.Send(msg);
    }
}

where dsRecipients is a Dataset populated with your recipients.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top