Home > Back-end >  MailKit: Search query to get a certain range of Uids from the server
MailKit: Search query to get a certain range of Uids from the server

Time:09-25

Currently working with Mailkit but having problem getting a certain range from the imap server

 var uids = await client.Inbox.SortAsync(SearchQuery.All, new [] {OrderBy.ReverseDate});

This helps me get all the uids from the server but in case I want only 10 I don't know how to achieve it. Should I get all the Uids and then trim it down to 10 uids to further fetch the body structure.

CodePudding user response:

The IMAP protocol doesn't have a way to get back only 10 results, but you can limit the UID range it searches and/or sorts.

var uids = await client.Inbox.SortAsync(SearchQuery.Uids (subRange), new [] {OrderBy.ReverseDate});
  • Related