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

Free Support Forum - aspose.com

OutOfMemory error while trying to extract a message


I’m getting the following exception while trying to extract a message from a PST file:

Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
at com.aspose.email.zawd.c(SourceFile:1334)
at com.aspose.email.zawd.a(SourceFile:1207)
at com.aspose.email.zavu.a(SourceFile:132)
at com.aspose.email.zavz.a(SourceFile:1913)
at com.aspose.email.zavz.b(SourceFile:1854)
at com.aspose.email.zavz.b(SourceFile:347)
at com.aspose.email.zavz.a(SourceFile:305)
at com.aspose.email.PersonalStorage.extractMessage(SourceFile:675)
at TestProject.main(TestProject.java:35)

Below is my code:

PersonalStorage pst = PersonalStorage.fromFile("test.pst");
FolderInfo folderInfo = pst.getRootFolder().getSubFolder("Inbox");
MessageInfoCollection messageInfoCollection = folderInfo.getContents();
MessageInfo messageInfo = (MessageInfo) messageInfoCollection.get_Item(712); // this is the number of message which causes the exception
MapiMessage message = pst.extractMessage(messageInfo);

How can I solve this issue?


Thank you for the issue description. To help you, we need to know the following:

  • The PST file (you can compress it to a ZIP archive and upload it or use Google Drive or Dropbox)
  • The version of Aspose.Email you used
  • The version of the operating system on which the error appears

Hi @Andrey_Potapov,

The PST file is from my company I work and cannot be public shared.
How can I send it just for you?


You can send the file using a private message email.png (43.6 KB).

Hi @Andrey_Potapov,

Here is the PST file.


Kelbertest2.zip (67.7 KB)

Thank you for the PST file. I reproduced the error and received the same result for the first message. I’ve logged the issue in our tracking system with ID EMAILJAVA-34865. Our development team will investigate this case. You will be notified when it is fixed.

Hi @Andrey_Potapov,

I would like to know if you’ve got a solution for this issue.
I have a software running on a customer which needs this problem solved as soon as possible.



Our development team does its best. The error you described will be fixed in Aspose.Email 21.5. We apologize for any inconvenience.

Hi @Andrey_Potapov,

What’s the timeframe for this solution please?


Aspose.Email 21.5 will be released towards the end of May.

Please note, the data of multivalued named properties has an invalid format in the source PST file. There are string values instead of multi-valued strings: invalid_data.png (39.8 KB). The new implementation of the message extraction will catch and handle the exception and pass the invalid property data as is.