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 ?