2

I have implemented IMAP Idle client using this example.

https://github.com/jstedfast/MailKit/blob/master/Documentation/Examples/ImapIdleExample.cs

I have millions of emails. I am saving message ids of emails as I am reading them.

In an event where computer/server hosting code is shutdown or restarted.

Is it possible to start reading emails after specific message id.

I do not want re fetch all emails which are already read by code.

Khalil
  • 1,047
  • 4
  • 17
  • 34

1 Answers1

1

Instead of saving the MimeMessage.MessageId, why not just save which UniqueId's your program has seen? They don't change between session and they are sequentially ordered.

This is how every IMAP mail client in the world avoids re-downloading the same messages over and over.

jstedfast
  • 35,744
  • 5
  • 97
  • 110
  • I am saving unique ids. How do I skip emails by unqiue ids in mailkit? – Khalil Mar 28 '20 at 16:57
  • How would you do it if UniqueIds were ints or strings? Do it the same way with UniqueIds. – jstedfast Mar 28 '20 at 18:16
  • Thanks for the pointers, I had to use SearchAsync to get uniqueids. I did not ask my last question correctly. I was actually asking what methods to use get unique ids before fetching records. – Khalil Apr 01 '20 at 01:53
  • Ah, as you discovered, the Search methods return UIDs. Search (SearchQuery.All) will get you the full list. – jstedfast Apr 01 '20 at 02:01