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

Free Support Forum - aspose.com

Order in MessageInfoCollection

I am using Aspose.Email

Both ImapClient and ExchangeClient give me a messageInfoCollection. I am wondering whether that collection has any particular order or user can set it up.

For example, I got 50 emails using ListMessages(50). Are these 50 emails the oldest, newest emails in the mailbox folder? Or they are the first 50 emails sorted by subject, from? Or they are just randomly picked in this mailbox folder? Thanks.

Hi Xu,

We are sorry for a delayed response.

After experimentation with the ListMessages(int) method, it is found that it fetches the latest N number of emails sorted on oldest first.These have been tested with a number of scenarios and the results are the same.

Using the EWSClient on Aspose.Email 4.2, ListMessages(int) is returning the the newest messages first. Is there any way to get ListMessages to return the top X oldest messages?

Hi Brian,

There is no such method available that can retrieve the X oldest messages from the mailbox. The oldest messages in the inbox can date back to very old list and can be queried using the ExchangeQueryBuilder option with ListMessages. Please use the overloaded member function of ListMessages for this purpose:

client.ListMessages("inbox", 10, Query);