Thursday, July 15, 2010

System.Net.Mail send message without recipient

Programmer Question

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.



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails