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