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

Free Support Forum - aspose.com

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)

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

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.

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

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) {


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.