Mac OS X Mail (MBOX) to EML Conversion

Hello,


I have a need to convert many Mac mbox files to EML so they can be read in outlook or other email clients. Is this possible with Aspose.Email?

I have looked at the documentation and see you support MBOX, but there are many types of MBOX formats used.

Thank you!

Hi Scott,


Thank you for using Aspose.Email.

Aspose.Email provides the facility to read messages from Mbox storage file as well as save these to local disc. Please refer to the following code sample that reads a MBox storage file and saves the messages from it to EML format. Please feel free to contact us if you have any other inquiry related to Aspose.Email. We’ll be glad to assist you further.

Sample Code:

// Open the storage file with FileStream
FileStream stream = new FileStream(@“Mbox_Storage_File.mbox”, FileMode.Open, FileAccess.Read);

// Create an instance of MboxrdStorageReader class and pass the stream
Aspose.Email.Formats.Mbox.MboxrdStorageReader reader = new Aspose.Email.Formats.Mbox.MboxrdStorageReader(stream, false);

// Start reading messages
MailMessage message = reader.ReadNextMessage();


int i = 0;

// Read all messages in a loop
while (message != null)
{

// Manipulate message - show contents
Console.WriteLine("Subject: " + message.Subject);

// Save this message in EML or MSG format
message.Save("Eml "+ i + “.eml”, MailMessageSaveType.EmlFormat);

i++;

// get next message
message = reader.ReadNextMessage();
}

// Close the streams
reader.Dispose();

stream.Close();

Thanks for the reply.


I have tried the sample you listed (it’s also in the docs), but it is not working with Mac based MBOX files. The first call to ReadNextMessage() returns null after it appears to read through the entire stream. After the call, I checked the position of the underlying stream and its at the very end of the file. It’s as if it can’t find what it is looking for and continues to read until it gets to the end.

I have tested with several MBOX files and get the same result.

Is this because they were originally on a Mac, or is there some other reason I am seeing this?

Thanks,

I think I now see the problem. In doing some research, it appears there are four major types of MBOX implementations:

  • MBoxO
  • MBoxRD
  • MBoxCL
  • MBoxCL2
When parsing MBoxRD files, the parser should be searching for "From " to start out a new email. Notice the space after the word From. It appears Aspose is searching for “From” (with no space). This causes problems if one of the header or body lines starts with “From”.

Can you confirm that Aspose is searching for “From” and not "From " to start a new message? If this is the case, can you please look into fixing this as outlined here.

In the meantime, I will try to pre-process these files prior to sending them through Aspose.




Hi Scott,

Could you please provide us with a sample Mbox file that can’t be read using Aspose.Email? We’ll investigate it further and assist you accordingly.

I have several thousand MBox files in the MBoxO (Eudora) format. If I manually change the ???@??? delimiter to a - (dash), then ASPOSE will process them, otherwise it simply skips the file.

Changing them by hand is not practical.

Is there a fix or release that will address MBoxO files available yet?

Hi Daniel,


Could you please share such a sample file with us for our investigation? We shall investigate the issue further and share our feedback with you after analyzing the file.
Aspose.Email.Formats.Mbox.MboxrdStorageReader reader = new Aspose.Email.Formats.Mbox.MboxrdStorageReader(stream, false);

This Code is not working in java
It gives compile time error : Aspose cannot be resolved to a type

@pradeepnegi

Formats are now under FileFormatType but if you are looking to read .Mbox then please use the following code snippet.

using (FileStream stream = new FileStream(dataDir + "ExampleMbox.mbox", FileMode.Open, FileAccess.Read))
using (MboxrdStorageReader reader = new MboxrdStorageReader(stream, false))
{
    MailMessage msg;
    while ((msg = reader.ReadNextMessage()) != null)
    {
        long currentDataSize = reader.CurrentDataSize;

        msg.Dispose();
    }
}

can you tell me how to convert mbox file to pst file
i am using this method of java email
PersonalStorage storage = MailStorageConverter.mboxToPst(“C:\Users\DELL\Desktop\mbox6.mbx”,“C:\Users\DELL\Desktop\output.pst”);
But, it’s not working properly.

@pradeepnegi

We have tested this with latest version of Aspose.Email for Java i.e 18.9 and it is working fine.
Please try with latest version and if the issue still exist then kindly share sample MBX file that you are trying to convert.

i am already using latest version of java emailmbox6.zip (250.6 KB)

please reply asap

@pradeepnegi

It seems no issue. Please find the converted PST file here:
https://www.dropbox.com/s/7kodmh0s3hf89il/mbox_output.pst?dl=0

Converted using the following code sample:

PersonalStorage storage = MailStorageConverter.mboxToPst(dataDir + "mbox6.mbx","D:\\32683\\output.pst");

Moreover, you may try with FileInputStream by reading MBX in stream and then passing stream to convert method.

this pst file size is 265kb whereas my mbox file size is 19mb and i have checked this file on outlook 2003, it doesn’t showing any mail in it.

@pradeepnegi

We have logged this issue with ID “EMAILJAVA-34437” for further investigation. You will automatically be informed here once we have more information to share.

can you tell me when this issue could be resolved, because i am thinking to buy this api

@pradeepnegi

We are working on this issue and we will update you as soon as we have more information to share.

@pradeepnegi

This issue has been resolved and we have prepared a hotfix release for you. Please download the release at this link and provide your feedback:
https://www.dropbox.com/s/jktt2unl6mfkynw/aspose-email-18.9.2-java.zip?dl=0

The issues you have found earlier (filed as EMAILJAVA-34437) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan

hi team,
when i am converting pst to mbox , there is a folder “Journal” , this folder in not converting into mbox , It throws an exception :
Exception in thread “Thread-5” class com.aspose.email.system.exceptions.KeyNotFoundException: The given key was not present in the dictionary.
com.aspose.email.system.collections.generic.Dictionary.get_Item(Unknown Source)