Free Support Forum -

Open MailMessage in Outlook editable


we want to save an Aspose.MailMessage in msg-format and stream the generated msg-file via our web application to the user. The user should edit the streamed message with his E-Mail-Application like Outlook.
Is this possible with Aspose?

All such attempts open an readonly message for the user.


Thank you for using Aspose.Email.

In order to save MailMessage so that it can be opened as editable, you need to specify the MSGFLAG_UNSENT in the message flags. Please have a look at the following code sample for your kind reference. It saves the message in editable form to disc and the same behavior should work for MemoryStream as well. Please try it at your end and let us know your feedback then.

MailMessage mailMsg = new MailMessage();

mailMsg.From = "";

mailMsg.To = "";

mailMsg.Subject = “Test Subject”;

mailMsg.Body = “Email Body”;

// create instance of type MapiMessage from MailMessage
MapiMessage mapiMsg = MapiMessage.FromMailMessage(mailMsg);

// set message flag to un-sent

// save it - Here you can save it to Memorystream in editable mode now.
MemoryStream ms = new MemoryStream();



Thank you for your help. Now it works fine.


We are glad to know that your issue is resolved. Please feel free to write us back if you have any other query in this regard.


I assume from this topic that the mail message should open with Outlook so that it could possible be edited before sending.

This is not happening for me. I am not prompted to open a file and it does not happen automatically. Is there something that I am still missing?

I am doing this in a web application.

Thanks in advance!

Hi Joe,

Thanks for writing to Aspose.Email support team.

Could you please send us the sample VB .Net web application which can be used to re-produce the scenario here. It will help us to provide assistance as soon as possible.


Please find code snip attached. It is basically the same code as above but converted to VB.

I trigger this from a button click.


Hi Joe,

I have tested your code and found it working fine.

I created a MSG file on disc by commenting the following line of code:


This resultant sample file “Sample01.msg” is double clicked and its automatically opened in Outlook 2010 as shown in the attached snapshot “ReadOnlyFields.png”. It can be seen that this message is opened as read only in Outlook and no “Send” button is visible over there.

Further test was performed by creating a sample file “Sample02.msg” where following line of code was enabled:


When this resultant sample file "Sample02.msg" is double clicked, its opened as editable message in outlook along with enabled "Send" button. A snap shot is attached here as "EditableFields.png".

Please give it a try and let us know your feedback. If still your problem is not resolved, please elaborate it more along with snap shots and environment detail. It will help us to identify the problem and assist you as soon as possible.

Hello Kashif,

Thank you for your reply.

The code you have supplied me does indeed work however not exactly in the way I would like it to work.

I do not have a need to save the msg file. The problem with the msg file is that the user has to go and retrieve it before sending.

I was hoping to be able to generate the file as a memory stream and then have the application open the file in Outlook automatically - working in a similar way to the way Aspose.Words does.

There is no need to store a copy of the email message on file - it can be regenerated by the application if needed.

I hope that this is clear.


Hi Joe,

Thanks for providing more detailed description.

Following is a sample code which performs the following tasks:
  1. Create mail message
  2. Convert it to MapiMessage
  3. Save MapiMessage to a memory stream
  4. Set content type of the Response
  5. Send MapiMessage as stream of bytes to client browser
Dim mailMessage As Aspose.Email.Mail.MailMessage = New Aspose.Email.Mail.MailMessage()
mailMessage.From = ""
mailMessage.TextBody = “any Body”
mailMessage.Subject = “any Subject”

Dim mailOutlookMapiMessage As MapiMessage = MapiMessage.FromMailMessage(mailMessage)

Dim mailStream As MemoryStream = New MemoryStream()
mailStream.Position = 0

Dim buffer() As Byte
Buffer = mailStream.ToArray() 'save in byte[] array

Response.Buffer = True

Response.ContentType = “application/”
Response.AddHeader(“content-disposition”, “attachment;filename=” + “Sample.msg”)

On execution of this code “Sample.msg” file will be downloaded to the client browser and user will have the option to open this file in MS Outlook in draft mode. After editing the mail, user will be allowed to Send the mail.

Please give it a try and let us know your feedback.

Hello Kashif,

Yes, this is what I was looking for.

Thank you for your help.


Hi Joe,

Its good to know you have got what you were in need of. In case you have any further query/inquiry related to Aspose.Email, please feel free to contact us for further assistance.