I would like to get the latest 100 UIDs from the inbox using MailKit. I am accessing a Gmail mailbox which does not appear to support the SORT extension so I am unable to use OrderBy.
Here is my code. The problem is that it appears to retrieve the oldest 100 emails rather the latest ones (which is how I would expect it to work). Is there a way to do this?
Option A - looks promising only gets the 100 oldest emails UIDs and I want the 100 newest:
imap.Inbox.Open(FolderAccess.ReadOnly);
var orderBy = new [] { OrderBy.ReverseArrival };
var items = imap.Inbox.Fetch(0, limit, MessageSummaryItems.UniqueId);
Option B - gets all UIDs by date order (but does not work on Gmail anyway):
imap.Inbox.Open(FolderAccess.ReadOnly);
var orderBy = new [] { OrderBy.ReverseArrival };
SearchQuery query = SearchQuery.All;
var items = imap.Inbox.Search(query, orderBy);
The IMAP server does not support the SORT extension.
The reason is to quickly scan the mailbox in order to improve responsiveness to user.