We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error when trying to sort by "from"


we are trying to load emails sorted from an exchange server. We are using the builder with following code:

client.listMessagesByPage(folderUri, builder.getQuery(), 50).getItems();

We get an Exception:

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)

It does work for

Can you fix this? It’s not our fault as far as we can see, since we don’t do anything different with the “getFrom()…” than with the other methods.

Thank you very much,



To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input email file.
  • Please create a simple application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Hello Tahir Manzoor,

thank you for the reply, we now have the Project you required: aspose.zip (1.3 KB)

In the zip there is a error.txt documenting the output and a Main.java, which when executed is producing the error. We cannot supply you with input email files, since we have encountered the error with several internal email accounts with Exchange Server 2010. Whoever recreating this will have to recreate it on his/her own Exchange Testmachine. It does also throw the error when the inbox is empty, but only with the mentioned method.

Thank you for your help, we hope you can fix it.

Best Wishes - Sigur


We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as EMAILJAVA-34973. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

1 Like

Hello Tahir,

do you have any news for us?



Your issue has been resolved. Please use the latest version of Aspose.Email for Java 21.12.

Hello (again) Tahir Manzoor,

thank you for fixing the exception. The next problem, sadly, arose when we tested the new version. Yes, we now can fetch the mails sorted by “from” - at least it seemed so at first. When inspected the list of emails we received though, we realized, that the order is not correct. Please check. You can use the codesample which we already supplied - the order is not correct. I.e. it doesn’t start with A.

Best wishes and thanks in advance


We have logged this problem in our issue tracking system as EMAILJAVA-35018. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

1 Like


It is to inform you that the issue which you are facing is actually not a bug in Aspose.Email. So, we have closed this issue (EMAILJAVA-35018) as ‘Not a Bug’.

Please note that the ordering only works by email address part, not by display name part. For example:

"b_user" <from2@host.com>
"a_user" <from1@host.com>
"d_user" <from0@host.com>
"d_user" <from0@host.com>
"a_user" <from1@host.com>
"b_user" <from2@host.com>