+1 vote

Hi,

with IMail.Save() it is possible to save a message in .eml format to disk.

Is there a way to "save" this .eml data with a stream or to a byte[] array?

I want to save this in a BLOB in a database, without first create a disk file.

by (450 points)
edited by

1 Answer

0 votes
 
Best answer

IMail.Save(string path) saves email in EML (MIME) format to disk.

Take a look at byte[] IMail.Render() which returns byte array or IMail.Render(Stream stream) which renders message to specified stream.

Please note that by default IMail.Render() renders empty BCC header. You can use the overload that takes bccRenderMode parameter to change that.

byte[] IMail.Render()   // BCC header is *not* rendered.
byte[] IMail.Render(AddressHeaderRenderMode bccRenderMode)

IMail.Render(Stream)    // BCC header is rendered.
IMail.Render(Stream, AddressHeaderRenderMode bccRenderMode)
by (297k points)
selected by
Wow that was quick. Thanks that was what I needed.
...