Sort messageInfoCollection results

Hi,
I would like to know if it’s possible to get the results from messageInfoCollection sorted?
I’m using Aspose.Email for Java.
Thanks

@kelberuc

Can you please explain your requirements and using which client you are fetching messages.

Hi @mudassir.fayyaz,

Please have a look at this function:

messageInfoCollection = pstFolder.getContents();
for (int i = 0; i < messageInfoCollection.size(); i++)
{
MessageInfo messageInfo = (MessageInfo) messageInfoCollection.get_Item(i);
MapiMessage message = pst.extractMessage(messageInfo);

}

I’d like to get the contents of this folder sorted by date descending (most recent first).

Thanks for your help

@kelberuc

I am afraid that no such option is available which can be used to sort PST messages. However you may develop some own logic and move the resultant messages as mentioned here to custom folders based on your criteria while adding and then access them. Please also check the API reference guide ExtractMessage overloads for your reference as well.