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

Free Support Forum - aspose.com

Exception "Negative Array Size"while creating PST using Aspose.Email for Java

Tried to create a PST based on customer emails, (overall over 1m emails), and started to get exception (after 610804 emails) :
at com.aspose.email.wu$a.a(SourceFile:1056)
at com.aspose.email.wu.a(SourceFile:461)
at com.aspose.email.wu.a(SourceFile:270)
at com.aspose.email.ayl.a(SourceFile:285)
at com.aspose.email.adz.g(SourceFile:1958)
at com.aspose.email.adz.d(SourceFile:778)
at com.aspose.email.aqk.a(SourceFile:995)
at com.aspose.email.FolderInfo.addMessage(SourceFile:726)

After 610804 was not able to add anymore emails to the PST.
Please advise.


I have observed your comments. Can you please share source file and sample code so that we may further investigate to help you out.

This is the code that actually is doing the job :

static void createPST(String emlPath, List<String> emailFiles) {
	MapiConversionOptions options = new MapiConversionOptions(OutlookMessageFormat.Unicode);
	PersonalStorage pst = PersonalStorage.create("/tmp/mails.pst", FileFormatVersion.Unicode);
	FolderInfo tmpFolder = pst.getRootFolder().addSubFolder(Localization.PSTDEFAULTEXPORTFOLDER);
	EmlLoadOptions loadOption = new EmlLoadOptions();
	Charset utf8Charset = Charset.forName(CAConstants.UTF8);
	for(String emailFile : emailFiles) {
		addMessageToPSt(loadOption, options, emlPath, tmpFolder, emailFile);

static void addMessageToPSt(EmlLoadOptions loadOption, MapiConversionOptions options, String emlPath, FolderInfo folder, final String emailFileName) {	
	final MailMessage eml = MailMessage.load(emlPath + "/" + emailFileName, loadOption);
	final MapiMessage mapi = MapiMessage.fromMailMessage(eml, options);

As for emails data, I cant’ send it to you as it’s confidential and huge. But I guess you should have test data to test such large volume of emails.

You can clearly see from the exception I’ve sent that issue is inside your library.



I have worked with the issue shared by you and an issue with ID EMAILJAVA-34492 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.