Hi,
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,
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.
test.
Thanks,
Darshan
image011
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,
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
outlookMsg.Save(fileName);
[//message.Save](https://message.save/)(fileName,MailMessageSaveType.OutlookMessageFormatUnicode);
}
Hi Jason,
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);
outlookMsg.Save(“test.msg”);