Exception: An item with the same key has already been added on loading OLM file (C# .NET)

Hi I am using the following code with your latest dll (18.2)

But getting this error:- An item with the same key has already been added.
try
{
OlmStorage storage = new OlmStorage(Program.OLMFileName);

            foreach (OlmFolder folder in storage.FolderHierarchy)
            {
                if (folder.HasMessages)
                {
                    // extract messages from folder
                    foreach (MapiMessage msg in storage.EnumerateMessages(folder))
                    {
                        MessageBox.Show(msg.Subject);
                    }
                }

                // read sub-folders
                if (folder.SubFolders.Count > 0)
                {
                    foreach (OlmFolder sub_folder in folder.SubFolders)
                    {
                        MessageBox.Show("Subfolder: " + sub_folder.Name);
                    }
                }

            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

@ajaykumar2018

Thank you for contacting Aspose support.

It is requested to kindly share sample OLM file with us, so that we could investigate this issue in detail. You may share confidential files in a private message. For this purpose, please click on my name and find “Message” button.

How to read Olm file from aspose.Email in java
" OlmStorage storage = new OlmStorage(dataDir + “OutlookforMac.olm”); "
This Class is not present in the aspose 18.9.4.

@pradeepnegi

Thank you for writing back to us.

The support for Outlook for Mac Data File (.OLM) using Aspose.Email is added in version 18.10 so the previous versions does not support OLM file.

Thank you for reply

This method throws and exception while reading olm file from this method.
OlmStorage storage = null;
try
{
storage = new OlmStorage(fin);
}
catch(Exception ep)
{
System.out.println(ep.getMessage());
}

exception : " An element with the same key already exists in the dictionary"

@pradeepnegi

We were able to reproduce this issue and it has been logged with ID “EMAILJAVA-34478” for further investigation. You will automatically be informed here once we have more information to share.

I am facing same issue while reading olm file, is it solved or not. please reply fast

@praw,

The associated issue has been marked as resolved in upcoming release of Aspose.Email for Java 19.1. We request for your patience and will share automatic notification with you once the product will be available online.

can you tell me when will you release Aspose.Email 19.1

@praw,

I regret to share that at present Aspose.Email for Java 19.1 has not been rolled out and is pending. We request for your patience till the time the product will be shared online. We will share notification with you once it will be shared.

Tried the code with new dll 19.1.1.0 but issue is still there. What is the status of this?

@ajaykumar2018,

I have observed your comments and reopened ticket. We will share good news with you soon.

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

is there any method to get all folder in olm with message count

@praw,

I request you to please visit this documentation link for reading OLM files and get folders and sub folders.

I have already read this code , but the problem is that i can’t get each folder path.
please check with this sample olm file : Outlook2.zip (326.1 KB)

@praw,

I have observed your requirements and regret to share that at present the requested support is unavailable in API. An issue with ID EMAILJAVA-34497 has been created in our issue tracking system to provide requested support. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

hi team,
there is an folder in my olm file named as “Address book” , it doesn’t shows any mails in this folder. But when extract olm file it has mail in this folder. Please check it in given file : Outlook2.zip (326.1 KB)

@praw,

I suggest you to please try using following sample code to enumerate Address Book contents.

public static void TestOLM()
{
    String dataDir="C:\\Email\\Outlook2\\";
    OlmStorage storage = new OlmStorage(dataDir + "Outlook2.olm");
    try
    {
        for (OlmFolder folder : storage.getFolderHierarchy())
        {
             System.out.println("Folder Name : " + folder.getName());
            if(folder.getName().compareTo("Address Book")==0)
            {
                for (MapiMessage msg : storage.enumerateMessages(folder))
                {
                    System.out.println("Subject: " + msg.getSubject());
                }
            }


            if (folder.hasMessages()) {
                // extract messages from folder
                for (MapiMessage msg : storage.enumerateMessages(folder)) {
                    System.out.println("Subject: " + msg.getSubject());
                }
            }

            // read sub-folders
            if (folder.getSubFolders().size() > 0) {
                for (OlmFolder subFolder : folder.getSubFolders()) {
                    System.out.println("Subfolder: " + subFolder.getName());
                }
            }
        }
    } 
    finally 
    {
        storage.dispose();
    }   
}