Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net mailmessage BCC and CC won't work

Tags:

c#

email

asp.net

Does anyone see anything wrong with this code:

MailMessage msg = new MailMessage();

msg.From = new MailAddress(WebConfigurationManager.AppSettings.Get("ReservationsFrom"));
msg.ReplyTo = new MailAddress(myRes.Email);
msg.To.Add(new MailAddress(WebConfigurationManager.AppSettings.Get("ReservationsTo")));
msg.CC.Add(new MailAddress(WebConfigurationManager.AppSettings.Get("ReservationsBcc")));

Try as I might, I can only get the 'To' address and the "ReplyTo" to work, the CC and the BCC never receive mail, even if I hard code the addresses in.

Am I missing something obvious here?

Edit: And yes, I am sure I am pulling the right addresses out of the web.config - like I said, even if I hard code a static address the BCC and CC never received email.

like image 469
E.J. Brennan Avatar asked Aug 22 '10 16:08

E.J. Brennan


2 Answers

I had similar problem and checked the smtp log. Looks like .net sends only one message, if "To" and "Cc"/"Bcc" adress are same.

like image 85
Sveco Avatar answered Oct 23 '22 04:10

Sveco


If static addresses hard-coded into the method calls aren't working, you're having a problem with delivery, not the addresses.

Can you telnet to port 25 on the smtp host you're using? Can you send an email to the test addresses from a regular email client (not web-based)?

like image 20
Dave Swersky Avatar answered Oct 23 '22 04:10

Dave Swersky