Error when trying to sort by "from"

Hello,

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

builder.getFrom().orderBy(true)
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)
com.aspose.email.zpt.a(SourceFile:7514)
com.aspose.email.zpt.b(SourceFile:7464)
com.aspose.email.zpt.a(SourceFile:7396)
com.aspose.email.zpt.a(SourceFile:7270)
com.aspose.email.zpt.a(SourceFile:7229)
com.aspose.email.zpt.a(SourceFile:7210)
com.aspose.email.zpt.a(SourceFile:8621)
com.aspose.email.zpt.listMessagesByPage(SourceFile:8480)

It does work for
builder.getSubject().orderBy(true)
and
builder.getInternalDate().orderBy(true)

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,

Sigur

@sigur

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

@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?

Greetings

@sigur

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

@sigur

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

@sigur

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:

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