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

Free Support Forum - aspose.com

InvalidCastException reading MapiMessage.Headers

This is not a critical bug, but I thought you may want to know about it. I often get an InvalidCastException when accessing MapiMessage.Headers:

Error processing MSG '2010.pst\BD\AAAAANCU0HWb4jdChiA4guF1iwrENCAA.msg' (System.InvalidCastException: Specified cast is not valid.
at Aspose.Email.Mail.Message.get_Priority()
at Aspose.Email.Mail.Message.()
at Aspose.Email.Outlook.MapiMessage.get_Headers()

Best regards,

Rob W

Here's a different stack trace from the same error:

Error processing MSG '\ANSI2.pst\Admin\AAAAABl0dIepLbFAlx0r3ALIPTvkQyIA.msg' (System.FormatException: The specified content type is invalid.
at Aspose.Email.Mime.ContentType.?()
at Aspose.Email.Mime.ContentType..ctor(String contentType)
at ?.?.?()
at ?.?.?(Byte[] )
at ?.?.?()
at Aspose.Email.Mail.MailMessage.Load(Stream stream)
at Aspose.Email.Outlook.MapiMessage.get_Headers()

Thank you,

Rob W

Also get an error reading Outlook.Pst.FolderInfo.DisplayName:

Error processing PST 'Old_Archive_ANSI.pst' (System.NullReferenceException: Object reference not set to an instance of an object.
at ?..get_Version()
at Aspose.Email.Outlook.Pst.FolderInfo.get_DisplayName()

Hi Rob,


Are you talking about the same PST file or have you extracted any messages from it. If you have a message file then please share it with us, along with your sample code to access message header information.

Thanks and regards,