Problems with IsOutlookMessage function

Any idea why this function would throw an error when it gets to the IsOutlookMessage() function? Its definitely getting the attachment data, as its listing the filename, etc in the debugger. As soon as I get to IsOutLookMessage() I get the dreaded “Object is not set to an instance of an object” error. Little help please?


Private Sub checkEmbedded(ByVal message As MapiMessage, ByVal folderInfo As FolderInfo)

Dim msgRow As DataRow
For Each msgAttch As MapiAttachment In message.Attachments
Dim embeddedMsg As New MapiMessage
If msgAttch.ObjectData.IsOutlookMessage = True Then
embeddedMsg = MapiMessage.FromStream(New MemoryStream(msgAttch.ObjectData.Data))
msgRow = emailTbl.NewRow()
msgRow(1) = embeddedMsg.Subject
msgRow(2) = embeddedMsg.Attachments.Count
msgRow(3) = “Yes”
msgRow(4) = folderInfo.DisplayName
emailTbl.Rows.Add(msgRow)
emailTbl.AcceptChanges()
checkEmbedded(embeddedMsg, folderInfo)
End If
Next
End Sub

This message was posted using Page2Forum from IsOutlookMessage Property - Aspose.Network for .NET

Hi,


Thanks for your inquiry.

Please update the code as below to handle both embedded messages and regular attachments.

If Not msgAttch.ObjectData Is Nothing AndAlso msgAttch.ObjectData.IsOutlookMessage Then
embeddedMsg = MapiMessage.FromStream(New MemoryStream(msgAttch.ObjectData.Data))
msgRow = emailTbl.NewRow()
msgRow(1) = embeddedMsg.Subject
msgRow(2) = embeddedMsg.Attachments.Count
msgRow(3) = “Yes”
msgRow(4) = folderInfo.DisplayName
emailTbl.Rows.Add(msgRow)
emailTbl.AcceptChanges()
checkEmbedded(embeddedMsg, folderInfo)
Else
msgAtt.Save(msgAtt.FileName)
End If

Thanks. That did actually get my code working, but its not detecting an embedded email that I know is in there. Are there any additional ways I should be checking for embedded emails other than the IsOutlookMessage() property?

Hi,


This method should work with the embedded messages. Could you please post a sample message for our testing? We will check at our end. You may zip and send using the “Contact” button --> “send saqib.razzaq an email” on top of this thread.

ok, message sent

Hi,


I am sorry but I could not reproduce the issue at my end. Please find the attached sample VB.NET project that I used to test with your MSG file. I was able to get the embedded MSG and then the other attachment inside it.

Well Im reading the messageInfo from a PST, and the email that i sent you is included in that pst. Could it be a problem reading the pst into a memorystream and it not being saved? ill send you the my additional code

Hi,


I have reproduced this issue by loading the sample file from a PST. I have also logged this bug in our issue tracking system (ID: 20097). We will look into it and will inform you when a solution becomes available. Sorry for the inconvenience.

Ok, do you have any ETA on how long this would take? We are looking into using this software in an application that is currently in the final stages of development, and if we can get this added in also, it would be a great addition.


Thanks,

Marcellus

The issues you have found earlier (filed as 20097) have been fixed in [this update](http://www.aspose.com/community/files/51/.net-components/aspose.network-for-.net/entry262044.aspx).

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The new version fixed this problem with first-level embedded messages, but when it tried parsing an attached message that is inside another attached message, then I’m getting an error of:


Unable to cast object of type ‘System.IO.MemoryStream’ to type ‘Aspose.Network.Outlook.Storage.xe7be411416cfcd54’

I tried reading in the attached message from a a memory string:


Dim ms As New MemoryStream(msgAttch.ObjectData.Data)
embeddedMsg = MapiMessage.FromStream(New MemoryStream(msgAttch.ObjectData.Data))

And also tried saving the attached message, and reading it in:

Dim attchPath As String = Application.StartupPath & “” & msgAttch.FileName
msgAttch.Save(attchPath)
embeddedMsg = MapiMessage.FromFile(attchPath)

I get the same error either way; And If I open the message in outlook, the embedded message attachment shows up incorrectly, just like it was with the first-level embedded message before the update.

Hello Marcellus,


We will look into it and will get back to you shortly. Sorry for the inconvenience.

The issues you have found earlier (filed as 20623) have been fixed in [this update](http://www.aspose.com/community/files/51/.net-components/aspose.network-for-.net/entry264900.aspx).

This message was posted using Notification2Forum from Downloads module by aspose.notifier.