In ASP.NET I am sending a MailMessage but it won’t go through. The code I am using is
message.To.Add(email1 + ", " + email2 + ", " + email3);
When I do this I never receive my mail. However if I use this code:
message.To.Add(email1 + ", " + email2);
It sends just fine every time. Anybody know what is going on here? All 3 emails are the same (for testing purposes) and have been verified to be correct while debugging. I tried inserting a different email address for the third and still nothing went through. I may be missing something obvious…
EDIT:
Everyone is telling me to add them individually which may well be good advice if everyone agrees upon it. The reason I didn’t do this previously and I just tried it again with three seperate addresses and none of them were sent. Maybe I have another issue entirely if that is supposed to work?
EDIT: For anyone with the same problem in the future here is what I did. When creating the MailMessage I didn’t create it with any parameters and instead specified the From parameter seperately. I wrapped the From and all To emails in new MailAddress() and the combination of all those changes appeared to work.
The
Toproperty of MailMessage is a collection, so you should callmessage.To.Add3 times if want to send to 3 email addresses.