5

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.

E.J. Brennan
  • 45,870
  • 7
  • 88
  • 116
  • See the answer to this http://stackoverflow.com/questions/23992114/sending-emails-with-bcc-list-not-working - appears to be the same and explains why. – GlennG Feb 10 '16 at 05:36

2 Answers2

5

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

Sveco
  • 66
  • 1
  • 2
2

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)?

Dave Swersky
  • 34,502
  • 9
  • 78
  • 118
  • Yes and yes, it is weird. Even if I put the same address in all 3 places (to, cc, bcc), only the 'to' is working. I've tried all the obvious stuff. Going to try a new smpt host and see if it works any better... – E.J. Brennan Aug 22 '10 at 16:15
  • Check the email header that is received as well, make sure they're actually in there... – Dave Swersky Aug 22 '10 at 16:17
  • I think it must be my ISP..tried another SMTP host and it worked fine. I'll take it up with them. – E.J. Brennan Aug 22 '10 at 16:42