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

there is an another issue with that , there is an folder in olm file named as “Calendar”. but doesn’t shows it.

@praw,

I have written a recursive method to iterate through all folders and sub-folders and it reads all folders.

public static void TestOLM()
{
    String dataDir="C:\\Email\\Outlook2\\";
    OlmStorage storage = new OlmStorage(dataDir + "Outlook2.olm");
    try
    {
        for (OlmFolder folder : storage.getFolderHierarchy())
        {
            ReadFolders(folder, storage);
        }
    }
    catch(Exception s)
    {
        s.printStackTrace();
    }
}

public static void ReadFolders(OlmFolder folder, OlmStorage storage)
{
    if (folder.getSubFolders().size() > 0)
    {
        for (OlmFolder sub_folder : folder.getSubFolders())
        {
            ReadFolders(sub_folder, storage);
        }
    }
    else
    {
        System.out.println("Subfolder: " + folder.getName());
        if (folder.hasMessages())
        {
            // extract messages from folder
            for (MapiMessage msg : storage.enumerateMessages(folder))
            {
                System.out.println("Subject: " + msg.getSubject());
            }
        }
    }
}

can you suggest me how do i create full path of each folder by reading olm file recursively

@praw,

Can you please explain the details about full path you are inquiring.

There is an issue with an olm file while reading.
It throws an exception :class com.aspose.email.system.exceptions.FormatException: One of the identified items was in an invalid format.
Outlook for Mac Archive.zip (2.8 MB)

@pradeepnegi,

I have worked with the OLM file shared by you and have been able to observe the issue specified. An issue with ID EMAILJAVA-34511 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

There are several issues while reading olm file, There are several exceptions generating like: values cannot be null, One of the identified items was in an invalid format.,.etc. please let me know when it will be fixed.

@pradeepnegi,

We will share good news with you as soon as the issues will be fixed for associated tickets and shared source files.

Hi, i have tried to read olm file with your latest dll 19.2.0.0 [C#] but still facing the same issue

“An item with the same key has already been added.”

Please let me know how to resolve this issue? Please update me soon.

@indianseomarketer

We will share good news with you as soon as the associated tickets will be resolved.

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

there is another issue in another file : test.zip (3.5 MB)
class com.aspose.email.system.exceptions.ArgumentNullException: Value cannot be null.
Parameter name: key
com.aspose.email.system.collections.generic.Dictionary.get_Item(Unknown Source)
com.aspose.email.amn.a(SourceFile:111)
com.aspose.email.OlmStorage$a.hasNext(SourceFile:252)
OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1437)
OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1479)
OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1479)
OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1479)
OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1479)
OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1479)
OlmReadFrame$AddTreeThread.run(OlmReadFrame.java:1375)
at com.aspose.email.system.collections.generic.Dictionary.get_Item(Unknown Source)
at com.aspose.email.amn.a(SourceFile:111)
at com.aspose.email.OlmStorage$a.hasNext(SourceFile:252)
at OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1437)
at OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1479)
at OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1479)
at OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1479)
at OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1479)
at OlmReadFrame$AddTreeThread.getFolder(OlmReadFrame.java:1479)
at OlmReadFrame$AddTreeThread.run(OlmReadFrame.java:1375)

@pradeepnegi,

I have worked with the sample file shared and have been able to observe the issue. An issue with ID EMAILJAVA-34520 has been created in our issue tracking system to investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hi Team,

What is the update of OLM Related issues? Have your development team resolved the same?

Please provide us the updated version of the same.

Kindly update ASAP

@ajaykumar2018,

I like to inform that this issue is going to resolved tentatively in Aspose.Email 19.4. I request for your patience until issue get resolved.

Hi Adnan,

I have used your 19.4 version but issue is still there in this DLL also

I an using the code " storage = new OlmStorage(filename);" but getting this error

System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary2.Add(TKey key, TValue value)
at #=zvmgQAt_FxmyC25ABOSlxEBJqWmd0xN9Szw==.#=zDnhyEkw=()
at #=zvmgQAt_FxmyC25ABOSlxEBJqWmd0xN9Szw==.#=zmQgkJC8=()
at Aspose.Email.Storage.Olm.OlmStorage…ctor(String fileName)

Please let me know when this issue will get resolved?

@indianseomarketer,

I like to share there that at present Aspose.Email for Java 19.4 has not yet been shared online. We will share the good news with you in the form of notification once the issue will be fixed.

Actually i am trying with C# and 19.4 is available

@indianseomarketer,

Please provide the working sample along with source file that you have tested so that we may verify it further on our end. Secondly, if the issue is not being resolved in Aspose.Email for .NET 19.4 then most likely it is not going to be part of Aspose.Email for Java 19.4 as well. We may have to wait till Aspose.Email for Java 19.4 is released. If the logged issue is not resolved, I will try to get ETA for you.

Thanks Mudassir,

This is the code which i am using

OlmStorage storage = new OlmStorage(myFileName);

But it is not possible for me to share the file as this is confidential as well the size of file is so large.

Would you please tell me ETA of your next version of DLL Release , so that we will be sure that my issue will get resolved on that date.

Thanks :slight_smile: