How do I save MailMessage object to the disk? The MailMessage object does not expose any Save() methods.
I dont have a problem if it saves in any format, *.eml or *.msg. Any idea how to do this?
How do I save MailMessage object to the disk? The MailMessage object does not expose any Save() methods.
I dont have a problem if it saves in any format, *.eml or *.msg. Any idea how to do this?
Here's an extension method to convert a MailMessage to a stream containing the EML data. Its obviously a bit of a hack as it uses the file system, but it works.
You can then take the stream thats returned and do as you want with it, including saving to another location on disk or storing in a database field, or even emailing as an attachment.
For one reason or another the client.send failed (right after an actual send using that method) so I plugged in good 'ole CDO and ADODB stream. I also had to load CDO.message with a template.eml before setting the .Message values. But it works.
Since the above one is C here is one for VB
For simplicity, I'll just quote an explanation from a Connect item:
You should be able to use the empty constructor instead of the one listed, as it won't be sending it anyway.
If you are using Mailkit. Just write below code