We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Fail to load msg file to MailMessage

Hi,


we use Aspose.Email.Mail to read msg file and prodvide the data inside the file e.g. From, To, Subject, Sent date etc. to another program.

this is running on a server, which gets triggered when an email msg has been saved there.

now, when we save the msg file using Outlook 2007 Professional Plus, it works… but when we try to save the emails from Outlook 2010 Pro Plus, it throws an exception and loading the msg line…


eMailMessage = Asponse.Email.Mail.MailMessage.Load(_msgStream);



When using Outlook 2007 Pro Plus - works fine

When using Outlook 2010 Standard - The code above throws an exception: Object reference not set to an instance of an object.

Hi Chris,


Thank you for writing to Aspose support team.

I have tried to reproduce this issue with the latest version of Aspose.Email for .NET 4.1.0 but I am afraid to share that the issue is not reproducible at my end. Could you please give it a try using this latest version and let us know your feedback? We will look into it and assist you further.

Hi Kashif,


I have uploaded the latest version of your dll, and we still have the error. Same behaviour.

Hi Chris,


I am afraid but I am unable to face any such error. With the provided sample file and following sample code, the MSG file is loaded successfully by Aspose.Email for .NET 4.1.0 and saved to EML as well. I have attached the output of code, screenshot of output and the converted EML file here for your reference. Could you please provide us complete call stack of the exception that you are getting? Also, provide details about the machine where this issue arises such as OS, Service Pack, etc.

Sample Code:

string dir = “EMAIL_549382\”;


MailMessageLoadOptions options = new MailMessageLoadOptions();

options.MessageFormat = MessageFormat.Msg;


Stream fs = File.OpenRead(dir + “Pres [test take 0].msg”);

fs.Position = 0;

MailMessage msg = MailMessage.Load(fs);

Console.WriteLine(“From:” + msg.From);

Console.WriteLine("To: " + msg.To);

Console.WriteLine("Subject: " + msg.Subject);

Console.WriteLine("Attachments Count: " + msg.Attachments.Count);