Archived Forum Post

Index of archived forum posts

Question:

Unique ID in IMAP for all Mailboxes

Sep 29 '16 at 08:06

I am looking for a unique identifier for IMAP server.

I tried the following functions GetImapUid() or GetHeaderField("ckx-imap-uid") but she returns unique id for a Mailbox.

Is it a way to uniquely identify an email IMAP Server ? (like UIDL on POP server)


Answer

The RFC 3501 specification says:

“2.3.1.1. Unique Identifier (UID) Message Attribute

A 32-bit value assigned to each message, which when used with the unique identifier validity value (see below) forms a 64-bit value that MUST NOT refer to any other message in the mailbox (folder) or any subsequent mailbox (folder) with the same name forever. Unique identifiers are assigned in a strictly ascending fashion”

“The unique identifier of a message MUST NOT change during the session, and SHOULD NOT change between sessions.”

“Any change of unique identifiers between sessions MUST be detectable using the UIDVALIDITY mechanism”

“The unique identifier validity value is sent in a UIDVALIDITY response code in an OK untagged response at mailbox (folder) selection time.”

The problem is that the UIDVALIDITY values of two mailboxes could be the same, although it is unlikely. In summary, given that UID values can be the same, and given that UIDVALIDITY values can be the same, a unique key would need to be composed of UID + UIDVALIDITY + mailbox name.

(The Imap.UidValidity property contains the UIDVALIDITY of the currently selected mailbox.)