Reputation: 1747
I am using System.Net.Mail.MailMessage to create and send an email message. For various reasons I do not want to use the .To.Add() or the .CC.Add() or the .Bcc.Add() methods to add recipients to the email. I want to add them via the .Headers.Add() method. (This gives greater control over the recipients).
However, when I come to send the message I get an exception stating "A recipient must be specified". It obviously does not realise that I have added recipients via the Headers.
Can anyone think of a workaround for this? Could I somehow override the method that is validating the message and throwing the exception?
Thanks very much.
Upvotes: 2
Views: 3257
Reputation: 28110
A common way of sending out mailings like this is to put the sender's address/return address (only) in the TO: field, and everything else hidden (like the BCC:). I don't know what you mean about specifying the recipients "in the headers", but your message is going to be blocked by most spam filters if it is out-of-the-ordinary, and having no visible recipients is surely that.
Upvotes: 0
Reputation:
Don't use that class. There is a lot alternatives on the market including opensource project.
Upvotes: 0