Reading MBOX File Throws InvalidOperationException

class com.aspose.email.system.exceptions.InvalidOperationException: Collection was modified; enumeration operation may not execute.
com.aspose.email.system.collections.generic.List$Enumerator.hasNext(Unknown Source)
com.aspose.email.MailMessage.y(SourceFile:4230)
com.aspose.email.MailMessage.a(SourceFile:4224)
com.aspose.email.MailMessage.b(SourceFile:3797)
com.aspose.email.MailMessage.a(SourceFile:247)
com.aspose.email.MailMessage.(SourceFile:242)
com.aspose.email.MailMessage.a(SourceFile:1502)
com.aspose.email.MailMessage.c(SourceFile:1420)
com.aspose.email.MailMessage.a(SourceFile:1391)
com.aspose.email.MboxrdStorageReader.a(SourceFile:261)
com.aspose.email.MboxrdStorageReader.readNextMessage(SourceFile:168)

Any ideas. When we process with the open MBOX library it is successful.

@dfplive,
Thank you for the stack trace output. Please check your results using the latest version of Aspose.Email. If the issue persists, please share the following:

  • input MBOX file
  • code example reproducing the error

MboxrdStorageReader reader = new MboxrdStorageReader(MBOXfilename, new MboxLoadOptions());
MailMessage msg;
while ((msg = reader.readNextMessage()) != null) {

it fails on the readNextMessage() call

The MBOX is 75GBs but we cannot provide it. I saw other Collection was modified issues that were resolved without data. We will try to create a testset that causes the issue.

If there was a method to get to a specific email in an mbox vs having to use the iterator we could work around this problem with a try catch.

@dfplive,
Thank you for the additional information. We will reply to you as soon as possible.

@dfplive,
Unfortunately, we need an MBOX file to investigate your case.

Could you please clarify which API is right for you to get a specific email from MBOX?

Here is the java code we are using. we make a reader then iterate that reader to get messages. If we could count the messages and then get them specifically by an ID that would solve the problem. We can do this in the PSTs using MessageInfoCollections

import com.aspose.email.MboxrdStorageReader;
import com.aspose.email.MboxLoadOptions;

MboxrdStorageReader reader = null;
try {
reader = new MboxrdStorageReader(MBOXfilename, new MboxLoadOptions());
try {
MailMessage msg;
String[] fromMarker = { null };
while ((msg = reader.readNextMessage()) != null) {

@dfplive

To investigate this issue, we need your MBOX file. Please ZIP and attach it here for testing. We will investigate the issue and provide you more information on it.

I am sorry this is NOT a data related issue. This would relate to ALL MBOX files. It is an attempt to normalize the features for PST/OST processing with mBOX. In PST/OST we can use multithreading to operate against but the limitation of the iterator in MBOX will not allow this. All we need is a counter or ID that we can thread against.

@dfplive

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input file. You can share any test file for which you are facing this issue.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.