开发者

System.Net.Mail send message without recipient

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 开发者_JAVA百科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.


Why not just add a junk recipient to the bcc field?


Don't use that class. There is a lot alternatives on the market including opensource project.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜