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

Free Support Forum - aspose.com

Folderinfo.GetContents() throws nullreference exception when tried to access the second time

I am getting a System.NullReferenceException when trying to access the outlook PST Folderinfo.GetContents() in my code. I am processing the results in batches i mean, i am processing the results in count of 5 at a time.

my code goes like this below ----

messageInfoCollection = subfolderInfo.GetContents()

’---- process the first 5 contents of this folder
'---- exit the class

once this batch is completed, i come back again to process the contents of same subfolderinfo.

when i call the same line of code as shown above, it throws ‘System.NullReferenceException’.

I have made sure that the subfolderInfo object is instantiated and I have made sure all the properties are populated.

When i checked through this over the net, it said that this was a known issue on the older version of aspose. I downlaoded the latest version that is released in july 2016 and i still get the same issue,…

i have written my code in vb.net.

Is this a known issue or am I missing something here…

Hi Rakesh,

Thank you for writing to Aspose Support team.

Please share your sample PST file with us along with your runnable code that we can use to reproduce the problem at our end. We’ll look into it for assisting you further.

Hi Iqbal,

It is a simple PST file with different level folder structures.

Since I am not allowed to share the code externally, can you please let me now if it is ok for you to attend a Webex meeting online at your available timeframe so that I can walk through over the issue.

I am available on India tome zone from 12.00pm to 8.00pm.

Please let me know if this works or we can plan other alternative.


Hi Rakesh,

We are sorry but we will not able to do a Webex with you. However, we have tested this issue by creating a sample PST file with 1000 test messages in its inbox. The following code is used to test the scenario you have shared and no such error is raised as you claimed. I have also attached the sample PST file here for your reference. The issue seems specific to your particular scenario and we’ll be in need of your sample code in order to investigate it further. You can use our sample PST file and create a simple console application that reproduces the issue you have mentioned. Please provide that to us for further investigation at our end.

Sample Code:

static void Main(string[] args)
    PersonalStorage pst = PersonalStorage.FromFile("FolderInfoNull.pst");
    folderInfo = pst.GetPredefinedFolder(StandardIpmFolder.Inbox);
    for (int i = 0; i < 1000; i+=5)
        CheckFolderInfoNullIssue(pst, i);

    Console.WriteLine("\nProgram Execution Completed...");

static void CheckFolderInfoNullIssue(PersonalStorage pst, int i)
    MessageInfoCollection msgs = folderInfo.GetContents();

    for (int iCount = i; iCount < (i + 5);iCount++ )