Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mailkit: What is the UniqueID

Tags:

c#

mailkit

after some googling without results about this I'll ask my questions:

What is the Mailkit.UniqueId?

In the metadata of the struct is simply reads

Represents a unique identifier for messages in a MailKit.IMailFolder

1) Is it unique only for let's say the Inbox but then the Bin or Sent might have the same number again (I doubt it from the messages I have retrieved so far)

2) Is it unique for the entire imap account?

3) Is it an id produced by mailkit or by the Imap Server?

4) What controls the incrementation of this Id to ensure it's unique.

5) What are the main differences between this UniqueID and the MessageID ?

like image 584
penCsharpener Avatar asked Mar 06 '18 14:03

penCsharpener


1 Answers

A MailKit UniqueId represents an IMAP UID. A UID as defined by IMAP is a numeric value that is unique per folder.

This means that a message in the Inbox can have the same UID as a different message in the Sent folder.

As per the comment discussion below your question, yes, UIDs are sequentially assigned which means that as long as messages are never deleted from a folder, the first message in the folder will have a UID of 1. The second message will have a UID of 2, etc.

This will not be the case, however, once messages start getting deleted from the folder.

For example, let's say we create a new IMAP folder and append 10 messages.

Their UIDs will be: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.

If I then go and delete messages: 1, 3, 5, 7, and 9, and then look at the messages still remaining in the folder, they will have the following UIDs: 2, 4, 6, 8, and 10.

like image 171
jstedfast Avatar answered Nov 11 '22 11:11

jstedfast