Unable to open .msg file after saving it to hard disk


My program creating .msg file and storing it on hard disk. I am getting error that file doesnt exist, which is not the case or i dont have permission to open file, which is not case either as i have admin rights on this machine.

I have attached .msg file question.

Error message looks as follows:

Hi Jason,

Could you please share your sample code that you have used in your application for creating the MSG file? If you are converting some sample EML file to MSG, I would request you to please share the source EML file for further investigation at our end. We’ll look into it and assist you accordingly.

I am using one proprietary API which provide me various parts of email like body, from,cc etc. I am composing Aspose MailMessage object from that information and lastly saving as .msg file.

I can print Body to text file and provide it to you but I suspect that body you can get from attached .msg file by just editing with notepad++.

Let me know if you still need something after above explanation and i will be glad to provide as much as I can.

Appreciate your help.

Hi Jason,

It seems you are not specifying the Message type while saving the message to disc. You can do this using the MailMessageSaveType argument as shown in the following sample code. Please give it a try at your end and let us know your feedback.

Sample Code:

MailMessage mailMsg = new MailMessage("From@domain.com", "To@domain.com", “Subject”, “Body”);
mailMsg.Save("MailMessage.msg", MailMessageSaveType.OutlookMessageFormatUnicode);

I was able to save and open the .msg file with given code but it didnt have any of body text.

It only had warning that i am using trial version of Aspose.

Following HTML I received from API as email body which i used to create .msg file.





Is there a way i can convert this HTML into EML compatible HTML?

I was able to resolve the problem. Whenever you are trying to compose an MailMessage with HTML body as given above. You have to set IsBodyHtml property true.

message.IsBodyHtml = true;

I was also able to convert above HTML into .eml file.

Hi Jason,

Its good to know that you have found the resolution to your mentioned issue. In order to avoid the evaluation message, you need to initialize license in your application. Please refer to our documentation section, Setting Licence, for more information in this regard.

I tried following code as suggested [here ](http://www.aspose.com/docs/display/emailnet/Creating+and+Saving+Outlook+Message+%28MSG%29+Files) without any success:

public static void Save(
MailMessage message,
string fileName)
var outlookMsg = MapiMessage.FromMailMessage(message);
// Save the message (MSG) file

Hi Jason,

I have tried the following sample code using Aspose.Email for .NET 4.0.0 and like to share that I can observe the valid formatted html body in Outlook 2010. Could you please give a try to the following sample code using above mentioned dll version and let us know your feedback?

// Create an instance of the MailMessage class
MailMessage mailMsg = new MailMessage();
// Set from, to, subject and body properties
mailMsg.From = "from@domain.com";
mailMsg.To = "to@domain.com";
mailMsg.Subject = “subject”;
mailMsg.HtmlBody = “

rtf example

creating an outlook message (msg) file using Aspose.Email.

MapiMessage outlookMsg = MapiMessage.FromMailMessage(mailMsg);