i have been searching all over the place for a way to get the count of unread emails in my Gmail account using GemBox.Email.Imap. So far i am able to connect, get the count of all mails but i need just the unread, is there anyone that have some experience using this Package?.
Gembox.Email.Imap get the count of unread mails
420 Views Asked by AcidRod75 At
2
There are 2 best solutions below
0
On
First you need an IMAP client; this is the client you get from the library:
private readonly MailKit.Net.Imap.ImapClient _client = new MailKit.Net.Imap.ImapClient();
Next, open access to your inbox folder:
await _client.Inbox.OpenAsync(FolderAccess.ReadOnly).ConfigureAwait(false);
Finally, get the list of messages with the flag "Not seen" and after return the count of values:
var result = _client.Inbox.Search(SearchQuery.NotSeen);
return result?.Count;
Okay, after a little bit i found out how to make this work, this is the code for a simple console aplication but it is extensible for any case.