tags:

views:

46

answers:

3

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.

+1  A: 

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

Paul Creasey
It's a good idea, but there are some other processes down the line that will log all the failed sends, and I was hoping to avoid that.
DEH
A: 

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

Pierre 303
Such as? Please elaborate on your answer so we can all use it?
MadBoy
Would you recommend any in particular?
DEH
MailBee (http://www.afterlogic.com/) is one alternative. Might be expensive depending on your situation but well worth it.
brendan
Http://mailsystem.codeplex.com. You can take the necessary code from there.
Pierre 303
A: 

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.

ewall