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

asked 06 Jul '11, 15:31

izak's gravatar image

izak
151
accept rate: 0%


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.

link

answered 06 Jul '11, 18:13

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.4k28
accept rate: 31%

edited 06 Jul '11, 18:14

Yes, that did it, thanks.

(07 Jul '11, 15:57) izak
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×53
×17

Asked: 06 Jul '11, 15:31

Seen: 388 times

Last updated: 07 Jul '11, 15:57