FolderInfo.HasSubFolders and ContentCount inaccurate for certain PSTs

FYI

We have observed PSTs which return misleading information for the following 2 properties:

  • FolderInfo.HasSubFolders
  • FolderInfo.ContentCount

These were returning false and 0 respectively. However, if we call FolderInfo.GetContents() and FolderInfo.GetSubFolders() we can see that the folder has items and subfolders.

On closer inspection, the following both returned null:
  • folderInfo.Properties[MapiPropertyTag.PR_CONTENT_COUNT];
  • folderInfo.Properties[MapiPropertyTag.PR_SUBFOLDERS];

So it seems like the PST in question is not 100% standard. It is my understanding that the PST was generated by a 3rd party tool.

Whether FolderInfo.HasSubFolders and FolderInfo.ContentCount should return the values they did in the absence of the underlying MAPI property is questionable. I am not sure what Aspose.Email should have done in this situation. Even if they both these properties existed I guess that there is no guarantee that they are accurate. The 3rd party vendor that created the PST could have set them to anything. One option would be for Aspose.Email to provide some sort of warnings/notifications if there are missing properties.

Opening the PST in Outlook shows the subfolders and items, so it seems like Outlook isn’t relying on those properties.

Anyway I have posted this here in case others come across this situation and as a hint for others to not rely 100% on HasSubFolders and ContentCount.

Hi Reuben,


Thank you for writing to Aspose support team.

We have analyzed your shared information and tested a few PSTs as well at my end. Unfortunately, I am not able to reproduce the issue at my end. Upon checking for existence of any such issue in our bug tracking system, I have found that the upcoming version of Aspose.Email for .NET 5.3.0 contains a fix for one such issue (EMAILNET-34733) where FolderInfo.HasSubFolders returns false for sub-folder items. It seems your concern may be related to the same. This new version will be available for download in a couple of days and you may check this issue with the new version for a fix.

In addition, I have also found that the FodlerInfo.GetCounts().Count property always returns correct content count and seems to be a much reliable alternative as compared to depending the flags mentioned above. Could you give it a try with your sample PSTs and share your feedback for the knowledge of others?