Question: I want to read emails between 2 UIDs or with the UIDs greater than a value.
imap.Search("UID > 83″, 1)
Is it possible?
Answer:
Yes. RFC 3501 lists the details of the IMAP Search command. The Chilkat.Imap.Search method passes the search criteria directly to the IMAP server, so you may formulate a string based on the information found in RFC 3501.
In this case, I’ve found this:
UID <sequence set>
Messages with unique identifiers corresponding to the specified
unique identifier set. Sequence set ranges are permitted.
But what is a sequence set? The answer to that is found further down in the IMAP grammar:
sequence-set = (seq-number / seq-range) *("," sequence-set)
; set of seq-number values, regardless of order.
; Servers MAY coalesce overlaps and/or execute the
; sequence in any order.
; Example: a message sequence number set of
; 2,4:7,9,12:* for a mailbox with 15 messages is
; equivalent to 2,4,5,6,7,9,12,13,14,15
; Example: a message sequence number set of *:4,5:7
; for a mailbox with 10 messages is equivalent to
; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and
; overlap coalesced to be 4,5,6,7,8,9,10.
Therefore, to get the set of UIDs for all messages having UIDs greater than (or equal to) 83, you do this:
imap.Search("UID 83:*", 1)
to get the set of UIDs of from UID 20 to UID 30 inclusive, do this:
imap.Search("UID 20:30″, 1)