Friday, 15 February 2013

c# - SmtpClient: Bcc ignored when using SmtpDeliveryMethod.SpecifiedPickupDirectory -


In 2010 (we were still using Net 2.0 on time), we had to face a problem when mail was not sent to the BCC recipient when

SmtpDeliveryMethod.SpecifiedPickupDirectory is used with SmtpClient.

After searching the web (and), I did the following solution:

  if (message.Bcc.Count> 0) {System.Text.StringBuilder bcc = New System.Text.StringBuilder (); (Int. I = 0; I & lt; message.BC.Count; i ++) for (BCC .app (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);   

The side effect of this solution was that the BCC recipient was visible in the header of sending mail , But in our case this was not an issue because the use of BCC logging purposes

A few days ago we started the Net 4.0 (finally) and the problem again. I tried to remove the solution and did not get any help from it.

Switching to SmtpDeliveryMethod.Network is not a solution because sending the mail is blocking and sending a mail (based on mail server load) while waiting for the user is not an option, sending mail async is not an option, because the mail Fails or Process crashes.

I can not find any solution on the Web for this problem, so does anyone have any ideas?

It does not work in .NET 4.0. But this is not a bug that has been designed in such a way. Take a look at this

It seems that there is a bug in Net 3.5 that allows you to implement the behavior you are viewing.

No comments:

Post a Comment