tags:

views:

1990

answers:

5

I am trying to use the System.Net.Mail.MailMessage class in C# to create an email that is sent to a list of email addresses all via BCC. I do not want to include a TO address, but it seems that I must because I get an exception if I use an empty string for the "TO" address in the MailMessage constructor. The error states that "TO" must not be the empty string. Surely it is possible to send an email using only BCC as this is not a limitation of SMTP. Is there a way around this?

ArgumentException The parameter 'addresses' cannot be an empty string. Parameter name: addresses

+1  A: 

You have to include a TO address. Just send it to a "junk" email address that you don't mind getting mail on.

David Kemp
I don't think you have to include a To-address.
Tommy Carlier
+5  A: 

Do the same thing you do for internal mail blasts where you don't want people to reply-to-all all the time.

Send it to yourself (or a dummy account), then add your BCC list.

Ben Scheirman
A: 

It doesn't even need to be a real e-mail address, I typically use [email protected] for TO, and NoReply@CompanyName for FROM.

FlySwat
+2  A: 

I think if you comment out the whole emailMessage.To.Add(sendTo); line , it will send the email with To field empty.

A: 

Just don't call the Add-method on the To-property.

Tommy Carlier