Getting ArgumentOutOfRangeException while loading some emails

I am getting ArgumentOutOfRangeException while loading some emails. Following is the code snippet that is causing the error (code is in scala):

val msgOpts = new MailMessageLoadOptions
msgOpts.setMessageFormat(MessageFormat.getEml())
msgOpts.setFileCompatibilityMode(FileCompatibilityMode.SkipValidityChecking)
val mailMsg = MailMessage.load(s"${dir}/${guid}.eml", msgOpts)
val mapiMsg = MapiMessage.fromMailMessage(mailMsg)

Following is the error I am getting:

com.aspose.email.system.exceptions.ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count.
Parameter name: index
Actual value was 0.
at com.aspose.email.system.collections.ArrayList.a(Unknown Source) ~[aspose-email-4.0.1.0-jdk16.jar:4.0.1.0]
at com.aspose.email.system.collections.ArrayList.get_Item(Unknown Source) ~[aspose-email-4.0.1.0-jdk16.jar:4.0.1.0]
at com.aspose.email.lv.a(Unknown Source) ~[aspose-email-4.0.1.0-jdk16.jar:4.0.1.0]
at com.aspose.email.lv.a(Unknown Source) ~[aspose-email-4.0.1.0-jdk16.jar:4.0.1.0]
at com.aspose.email.MapiMessage.a(Unknown Source) ~[aspose-email-4.0.1.0-jdk16.jar:4.0.1.0]
at com.aspose.email.MapiMessage.d(Unknown Source) ~[aspose-email-4.0.1.0-jdk16.jar:4.0.1.0]
at com.aspose.email.MapiMessage.b(Unknown Source) ~[aspose-email-4.0.1.0-jdk16.jar:4.0.1.0]
at com.aspose.email.MapiMessage.fromMailMessage(Unknown Source) ~[aspose-email-4.0.1.0-jdk16.jar:4.0.1.0]
at com.aspose.email.MapiMessage.fromMailMessage(Unknown Source) ~[aspose-email-4.0.1.0-jdk16.jar:4.0.1.0]
at com.aspose.email.MapiMessage.fromMailMessage(Unknown Source) ~[aspose-email-4.0.1.0-jdk16.jar:4.0.1.0]

Hi John,


Thank you for sharing your concern with Aspose support.

Could you please share some sample files with us for our investigation? We’ll look into these and assist you accordingly. Also, I would request you to please use the latest version of Aspose.Email for Java 4.0.1 in your testing and share your feedback with us.

I’ve attached the file which I am getting the error. This is a google calendar invite mail.

Hi John,


Thank you for contacting Aspose support team.

I have tested the sample file and observed the exception as stated above. This issue is logged in our issue tracking system as id. NETWRKJAVA-33371. Development team will look into this issue on its turn and will share their findings.

This thread is linked with this logged ticket so you will be automatically notified once the issue is resolved and updated dll is available online.

Please feel free to write us back if you have any other query in this regard.

Hi Kashif,

Thanks for the response. Can you tell me the expected time for a fix to be released.

Hi John,


The issue has been scheduled to be fixed in the upcoming version of Aspose.Email for Java 4.1.0. We’ll notify you here via this thread once the fix version is available for this issue. We appreciate your patience in this regard.