Null object returned when reading messages

Hello,
Please forward to the developer in charge :slight_smile:

For Each MyFolder As FolderInfo In PersonalStorage.RootFolder.GetSubFolders

For Each MyMSG As MapiMessage In MyFolder.EnumerateMapiMessages

If MyFolder.RetrieveFullPath.Contains(“Contacts”) = True Then

Dim MyContact As MapiContact = TryCast(MyMSG.ToMapiMessageItem, MapiContact)

* Bug: MyContact is null, and the originating MyMSG? See attached snapshot (exception.png)

I’ve seen some similar cases that when enumerate or get messages, null items are returned.
Unless it’s OK and expected by you, I think it’s abnormal.

But what’s the story in this case?
See my real PST tree (tree.png)
Inside the Contacts, there are 2 sub folders:
1st one has a contact inside
2nd one (marked as red) is an empty folder which causes the null object

My pst is generated by MS Office (and not a 3rd party app) so it should be considered fine standard

( I guess those folders are created when adding a message sender/recipient to the contacts )

exception.png (34.4 KB)

tree.png (71.1 KB)

@australian.dev.nerds

Please share the sample application that you are using along with input storage file. We will investigate the issue and share our findings with you. Thanks for your cooperation.