Error saving email as msg using email 4.3.0 java.lang.ArrayIndexOutOfBoundsException: -164

Hi.

I am extracting emails from pst and ost files and saving them in the file system as msg files. I am able to extract all of the but some also throw the following exception.
the stack trace is:

java.lang.ArrayIndexOutOfBoundsException: -1640
at com.aspose.email.tf.a(Unknown Source)
at com.aspose.email.te.a(Unknown Source)
at com.aspose.email.mx.a(Unknown Source)
at com.aspose.email.MapiMessageReader.readMessage(Unknown Source)
at com.aspose.email.MapiMessage.a(Unknown Source)
at com.aspose.email.MapiMessage.a(Unknown Source)
at com.aspose.email.MapiMessage.e(Unknown Source)
at com.aspose.email.mu.a(Unknown Source)
at com.aspose.email.internal.ap.a.a(Unknown Source)
at com.aspose.email.internal.ap.b.a(Unknown Source)
at com.aspose.email.MapiMessage.save(Unknown Source)
at com.vediscovery.unpack.email.MessageExtractor.saveMsg(MessageExtractor.java:65)
at com.vediscovery.unpack.email.MessageExtractor.run(MessageExtractor.java:44)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

My Method:

private void saveMsg(){
MapiMessage message;
String messageName = null;
try{
message = pst.extractMessage(entryId);

OutputStream out;
if (message.getSubject() == null || message.getSubject().isEmpty() == true){
messageName = “(” + messageNumber + “)”;
}else{
messageName = GetRidOfIllegalFileNameCharacters(message.getSubject()) + “(” + messageNumber + “)”;
}
// save this message to disk in msg format
out = new FileOutputStream(exportLocation + “\” + messageName + “.msg”);
message.save(out);
pstLogger.debug("[EXTRACTION]" + "Save Msg | " + “Message Type: " + messageClass +” | Pst Name: "+ pst.getDisplayName() + " | Saving message " + GetRidOfIllegalFileNameCharacters(message.getSubject()) + “…”);
message.dispose();
out.close();
}catch(MailException m){
Main.ERROR_COUNT += 1;

m.printStackTrace(new PrintWriter(sws));
pstLogger.error("Mail Item Processing Error " + " | PST Name: " + pst.getDisplayName() + " | Folder Name: " + folderName + " | File Name: " + messageName + " | Mail Message Exception Message: " + sws.toString());
}catch(IOException io){
Main.ERROR_COUNT += 1;
io.printStackTrace(new PrintWriter(sws));
pstLogger.error("Mail Item Processing Error " + " | PST Name: " + pst.getDisplayName() + " | Folder Name: " + folderName + " | File Name: " + messageName + " | File write exception Message: " + sws.toString());
}catch(Exception e){
Main.ERROR_COUNT += 1;
e.printStackTrace(new PrintWriter(sws));
pstLogger.error("Mail Item Processing Error " + " | PST Name: " + pst.getDisplayName() + " | Folder Name: " + folderName + " | File Name: " + messageName + " | Extract MSG file Exception Message: " + sws.toString());
}

}

I have attached the extracted msg and msg extracted manually from outlook 2010. I could not upload the pst ziped up. Might be too big.

Please let me know how to fix this error. it look like this happens when a message has an email as an attachment.

Thanks

Martin

Hi Martin,


I have tried to reproduce the scenario using your sample code and sample messages but could not succeed as these messages are successfully loaded and saved back on disc with no exception.

For further analysis I would like to request you to please send us the PST using any online storage like Dropbox etc.so that we may observe the issue here and provide solution as soon as possible.