How to Convert MBox File to PST File?

Dear support,

I am reading a MBox file using the following code

        string dataDir = "/private/var/root/Desktop/MyMessage/All Mail/Inbox/One.mbox";

        using (FileStream stream = new FileStream(dataDir, FileMode.Open, FileAccess.Read))
        using (MboxrdStorageReader reader = new MboxrdStorageReader(stream, false))
        {
            Aspose.Email.MailMessage mailMsg;
            while ((mailMsg = reader.ReadNextMessage()) != null)
            {
                long currentDataSize = reader.CurrentDataSize;

                mailMsg.Dispose();
            }
        }

I am reading one message at a time using fuction ReadNextMessage() and store this message mailMsg object of type Aspose.Email.MailMessage. Now i want to save this message into a pst file. Guide me how can write mail data of mailMsg object into the pst file. Suggest me best way to convert MBox file to PST file.

Thanks

@qtsoft,

Thank you for writing to Aspose support team.

You may please give a try to the following sample code which can be used to convert MBOX to PST.

int counter = 0;
PersonalStorage storage = MailStorageConverter.MboxToPst(@".\source.mbox",
    @".\output.pst",
    delegate (MailMessage message)
    {
        counter += 1;
    });

//Compare the number of messages in the source mbox and destinatio PST file
using (MboxrdStorageReader reader = new MboxrdStorageReader(@".\source.mbox", false))
{
    Console.WriteLine(reader.GetTotalItemsCount());
    Console.WriteLine(counter);
}

Thanks. It was help full. I had converted only one MBox file int PST. MailStorageConverter.MboxToPst(…) function read the MBox file and add a folder(name is Inbox) in newly created PST and populate that folder(Inbox) with mails of MBox.

My query is that I want to add my own folders and populate these folders with mails of their MBox file. For example…

I have a foder on my Desktop which contains many other folders and mbox file like in attached image Pic.png (11.1 KB)

Now I want to add these folders into pst file and populate these folder with mails of their mbox file. As folder N must be populate with its mbox file, folder 1 must be populate with its mbox file and with folder N,folder 3 must be populate with its mbox file etc. Basically I want to intact folder hierarchy. Is it possible in Aspose.EMail for Xamarin under Mac OS X .

Thanks

@qtsoft,

Could you please share such a sample MBox file with us having folders hierarchy? Aspose.EmailAPI doesn’t support such hierarchy structure while conversion of MBox to PST. We’ll further analyze your sample file for consideration at our end.

Dear Support,

Please tell me where I can upload the MBOX data or you need only screen shots of data to see the folders hierarchy.

Is it possible to intact folder hierarchy with other formats like eml, emlx because in Mail Clients which supports eml and emlx each folder populated with its own eml and emlx file for example Inbox folder will be populated its own eml and emlx, Sent Item folder will be populated its own eml and emlx etc. Is it possible to add Folder like Inbox, Sent Item, Drafts and other folders into newly created PST and can populate these folders with thier mails contained in eml and emlx file.

Thanks

@qtsoft,

Please share your sample MBox data file with us by attaching it here. Exporting the MBox to PST with exact folder structure is not supported at present by the API. Your sample PST file will help us analyze your requirements further for consideration.

Postbox.zip (1.4 MB)

You can download the sample MBox file an uncompress the downloaded file.

Follow the given path to get the MBox file

/Postbox/Profiles/c6ondeip.default/ImapMail/imap.gmail.com/[Gmail].sbd

All Mail mbox file contains mail do is of All Mail folder and Sent Mail mbox file contains mail do is of Sent Mail etc. Now I want to create All Mail folder in newly created PST and populate All Mail folder with mails of All Mail mbox file and so on. Through which I can intact folder hierarchy according to mail client on which mail account configured.

Thanks

@qtsoft,

Thank you for sharing the sample file. Please note that Aspose.Email API provides support for MBox files only and loading information from files as you have shared are not supported. If you can export these to Thunderbird’s MBox file format, the API will be able to read these for conversion to PST.

Thunderbird.zip (248.0 KB)

Again I am uploading the Thunderbird Mail client data.

You can download the sample MBox file an uncompress the downloaded file.

Follow the given path to get the MBox file. There

/Thunderbird/Profiles/gn1bl7el.default/ImapMail

All Mail mbox file contains mail do is of All Mail folder and Sent Mail mbox file contains mail do is of Sent Mail etc. Now I want to create All Mail folder in newly created PST and populate All Mail folder with mails of All Mail mbox file and so on. Through which I can intact folder hierarchy according to mail client on which mail account configured.

Thanks

@qtsoft,

We are sorry to share that support for retaining such hierarchy in output PST file is not possible with the API. Such requirement was raised earlier as well, but we have no such plans for provision of this feature in near future. Please feel free to write to us if you have any further query related to API.

Okay. One more thing, There are multiple mbox file in the attached zip file.

Thunderbird.zip (248.0 KB)
Can I convert all file in single attempt. For example

Case 1:
If I select Thunderbird directory then it is possible to convert all mbox into PST file file in single attempt.

Case 2:
If I select all mbox file then it is possible to convert all mbox into PST file file in single attempt.

@qtsoft,

Please note that Aspose.Email API supports MBox file which has all its emails embedded in one single MBox file. Support for such MBox files whose exported eml/emlx files reside outside is not available at the moment.