2

In 2010 (we were still using Net 2.0 at the time) we encountered a problem that mail were not send to Bcc recipients when using the SmtpDeliveryMethod.SpecifiedPickupDirectory with the SmtpClient.

After searching the web (link and link), i made the following workaround:

if (message.Bcc.Count > 0)
{
    System.Text.StringBuilder bcc = new System.Text.StringBuilder();
    for (int i = 0; i < message.Bcc.Count; i++)
    {
        bcc.Append(message.Bcc[i].Address);
        bcc.Append(";");
    }
    message.Headers.Add("Bcc", bcc.ToString());
    message.Bcc.Clear();
}

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.SpecifiedPickupDirectory;
smtp.PickupDirectoryLocation = PickupDir;
smtp.Send(message);

This workaround had as side-effect that the Bcc recipient was visible in the header of the send mail, but in our case this wasn't an issue as Bcc was used for logging purposes.

A a few days ago we switched to Net 4.0 (finally) and the problem resurfaced. I tried removing the workaround and that didn't help either.

Switching to SmtpDeliveryMethod.Network isn't a solution as the send method is blocking and keeping the user waiting (depending on the mail server load) while a mail is send is not an option. Sending the mail async isn't isn't an option too, as the mail is lost when the send fails or the process crashes.

I can't seem to find any solution on the web for this problem, so does anyone have any ideas ?

Community
  • 1
  • 1
Marc
  • 983
  • 2
  • 12
  • 28

1 Answers1

1

This doesn't work in .Net 4.0. But it is not a Bug it is designed that way. Take a look at this link

As it seems there is a Bug in .Net 3.5 that allows to implement the behavior you're looking for.

Romano Zumbé
  • 7,893
  • 4
  • 33
  • 55
  • If this combination is not supported (Bcc + PickupDirectory) it should be mentioned in the help pages of SmtpClient and/or MailMessage. – Marc Jun 21 '13 at 08:36