Splitting MBOX Files

Split MBOX Storage

Aspose.Email provides a method for dividing large mailbox files into manageable chunks. This helps improve performance and memory efficiency, especially when working with extensive email archives.

MBOX data is segmented with the split_into method of the MboxStorageReader class, optionally customizing the output file naming:

  • split_into(chunk_size, output_path)
  • split_into(chunk_size, output_path, part_file_name_prefix)

Parameters:

  • chunk_size: the approximate size of each chunk in bytes.
  • output_path: the folder path where the chunks are created.
  • part_file_name_prefix: the prefix added to the file name of each part.

The resulting parts are named part0.mbox, part1.mbox and so on, or <prefix>part0.mbox when a prefix is supplied.

The following code sample splits an archive into chunks of about 10 MB each:

from aspose.email.storage.mbox import MboxStorageReader, MboxLoadOptions

reader = MboxStorageReader.create_reader("input.mbox", MboxLoadOptions())

reader.split_into(10 * 1024 * 1024, "output_directory")

To add a prefix to the names of the resulting files, pass it as the third argument:

from aspose.email.storage.mbox import MboxStorageReader, MboxLoadOptions

reader = MboxStorageReader.create_reader("input.mbox", MboxLoadOptions())

reader.split_into(10 * 1024 * 1024, "output_directory", "chunk_")

See Also