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

Free Support Forum - aspose.com

Problem with setting attachment greater than 70 MB in PST File using Aspose.email for java

Hello Team,

I have a problem with setting a attachment size up to 70 MB in PST File. It say out of heap.What is the maximum size to set attachment in PST File.Please help me


Thank you for writing to Aspose Support team.

We have tested this issue at our end with the latest version of the API but were not able to observe any such problem as you have mentioned. The PST is generated fine and opens good in MS Outlook without any issue. Please give it a try at your end with the latest version of the API and let us know your feedback.

Sample Code:

<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”><pre style=“font-family: “Courier New”; font-size: 9pt;”>MapiMessage msg = new MapiMessage("from@domain.com", "to@domain.com", “Test 70MB att”, “Body”);

msg.getAttachments().add(“Test.txt”, new byte[7010241024]); //70 MB

PersonalStorage pst = PersonalStorage.create(“152112\test70Mb.pst”, FileFormatVersion.Unicode);

FolderInfo fi = pst.getRootFolder().addSubFolder(“Test”);



I have added a attachment with 125 MB. then it shows exception below this:-

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #ff2600} span.s1 {text-decoration: underline ; color: #0433ff} span.Apple-tab-span {white-space:pre}

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

at com.aspose.email.system.io.MemoryStream.setCapacity(Unknown Source)

at com.aspose.email.system.io.MemoryStream.b(Unknown Source)

at com.aspose.email.system.io.MemoryStream.write(Unknown Source)

at com.aspose.email.mw.write(SourceFile:321)

at com.aspose.email.dv.a(SourceFile:167)

at com.aspose.email.agh.a(SourceFile:377)

at com.aspose.email.agh.a(SourceFile:252)

at com.aspose.email.agh.a(SourceFile:265)

at com.aspose.email.agh.c(SourceFile:157)

at com.aspose.email.MailMessage.a(SourceFile:1402)

at com.aspose.email.MailMessage.b(SourceFile:1316)

at com.aspose.email.MailMessage.a(SourceFile:1238)

at com.aspose.email.MailMessage.load(SourceFile:1223)

at SysTools.MBOX_Reader.main


We have tested this at our end on a 64-bit system and 125 MB attachment file and no such exception is raised. Could you please share with us if you are using a 32-bit or 64-bit system? Also, please share your sample EML file with us for further investigation at our end.