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

Free Support Forum - aspose.com

Date of email .msg coming in as 01/01/0001

Hello,


I am using Aspose.Network 5.1.0.0 (2010.03.25) and loading in a .msg file from the filesystem. The date of the email is coming in as 01/01/0001. I am using Windows 7 (32 bit) and Outlook 2007 . The date comes in correctly in a previous version of Aspose. It is also working for a colleague with 64 bit Windows 7.

Code:

Aspose.Network.License lic = new Aspose.Network.License();
lic.SetLicense(@“Aspose.Total.lic”);

MailMessage msg = MailMessage.Load(@“Test.msg”);
DateTime date = msg.Date;

This happens with all emails I attempt. If you cannot reproduce this I can send you a sample.

Thanks
James

Hi James,

Could you please specify the format of message in MailMessage constructor. The above code will show date as 01/01/0001 because email is not loaded correctly in MailMessage class. The default format is eml.

It will work if you change the code as
MailMessage msg = MailMessage.Load(@“Test.msg”, MessageFormat.Msg);

Hello,


I am working in the same company and was previously recommended to use the following code to fix a date related issue…

Aspose.Network.Mail.MailMessage.Load(“Msg.msg”, Aspose.Network.Mail.FileCompatibilityMode.MostCompatible);

This code is working on my machine (Win 7 Pro) and failing on Jame’s machine (Win 7 Pro also).

Surely there must be a consistent mechanism to get this working. Can you please explain how to get this working on all machines?

Kind regards,
JP

Hi,

FileCompatibilityMode.MostCompatible argument in the constructor was introduced to fix Subject related issues for “eml” files only.

All the below statements can load eml files correctly:
MailMessage msg = MailMessage.Load(“test.eml”, FileCompatibilityMode.MostCompatible);
MailMessage msg = MailMessage.Load(“test.eml”);
MailMessage msg = MailMessage.Load(“test.eml”, MessageFormat.Eml);

But for loading msg files, MessageFormat.Msg must be passed as an argument as below:
MailMessage msg = MailMessage.Load(“test.msg”, MessageFormat.Msg);