How to create mail message draft

0 votes
asked Jun 26, 2015 by Rebex KB (8,210 points)

I'd like to create a mail message file (.MSG or .EML) to be opened in e-mail client (e.g. in Outlook). When an user opens the file, he/she can just fill the recipient's address and send the prepared message.

Unfortunately, the message files created using the MailMessage.Save method seems to be read-only (I cannot modify neither the recipient nor the message body}. I can only reply or forward the message.

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Jun 26, 2015 by Jan Sotola (16,920 points)

You can make the message read-write by setting the X-Unsent flag into the message headers:

var msg = new MailMessage();
msg.Subject = "Subject";
msg.Headers.Add("X-Unsent", "1");  // <-- that's it
msg.BodyHtml = "Mail body...";

It should work both for .EML and .MSG message formats.

...