0 votes
by (370 points)
edited

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
by (148k points)
edited

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.

by (370 points)
edited

Yes, that did it, thanks.

...