0 votes

If I want to search imap folder content and sort it by date descending. How can I achieve it?


1 Answer

0 votes
Best answer

If your IMAP server supports SORT extension:

List<ImapExtension> capability = client.SupportedExtensions();
bool supportsSort = capability.Contains(ImapExtension.Sort);

Use Search and Sort methods on IMAP client:

List<long> uids = client.Search()

Alternatively you could use the fact that uids are assigned in ascending order - you can easily search on the server and then simply sort on the client side.

by (298k points)