Mail message save, open

0 votes
asked Jul 6, 2011 by izak (180 points)
edited Jul 7, 2011

Hi

I want to save a mail message (.msg) that I have provided with a html body with to and from values. When I open this message with Outlook I want the message to behave like its ready to be sent, in other words all the options must be editable so that the user can edit it before sending. Is this possible?

Im using the following code

     Dim message As New MailMessage
     message.From = New MailAddressCollection("hugo@example.com")
     message.To = New MailAddressCollection("joe@example.com")
     message.Subject = "This is a simple message"
     message.BodyText = "Hello, Joe!"
     message.BodyHtml = "Hello, <b>Joe</b>!"
     message.Save(Filename, MailFormat.OutlookMsg)

Thanks Izak

Applies to: Rebex Secure Mail

1 Answer

+2 votes
answered Jul 6, 2011 by Lukas Pokorny (110,970 points)
edited Jul 7, 2011

Yes, this is easily possible, although it's not documented yet. Just add the following line to your code somewhere before the message.Save call:

    message.Headers.Add("X-Unsent", "1")

Example:

     Dim message As New MailMessage
     message.From = New MailAddressCollection("hugo@example.com")
     message.To = New MailAddressCollection("joe@example.com")
     message.Subject = "This is a simple message"
     message.BodyText = "Hello, Joe!"
     message.BodyHtml = "Hello, <b>Joe</b>!"
     message.Headers.Add("X-Unsent", "1")
     message.Save(Filename, MailFormat.OutlookMsg)

This should do the trick.

commented Jul 7, 2011 by izak (180 points)
edited Jul 7, 2011

Yes, that did it, thanks.

...