Anton Koval'
Anton Koval'

Reputation: 5053

gmail imap: get recently updated messages

is it any way (with IMAP) to retrieve only updated messages for some period of time? (or, perhaps, only their flags).
what i mean, with example:
i've checked my mbox with imaplib.IMAP4_SSL(...) at 4.00pm;
at 4.15pm i've gone to gmail web interface and marked one of my mails as "read";
at 4.30pm i want to check all updates in my mail box, for period in 4.01-now, through imaplib.IMAP4_SSL(...).

Upvotes: 2

Views: 485

Answers (2)

dkarp
dkarp

Reputation: 14763

For vanilla IMAP, you're out of luck. But if the IMAP server supports the CONDSTORE extension, you can do this. See RFC 4551 section 3.3.1 for the details. Generally, it involves keeping track of the folder's HIGHESTMODSEQ value and issuing a command like

A001 UID FETCH 1:* (FLAGS) (CHANGEDSINCE 12345)

Upvotes: 3

Trevor Ian Peacock
Trevor Ian Peacock

Reputation: 824

I don't think IMAP servers record when flags are set, just the fact they are set. I cant see anything the RFC that suggests otherwise. http://www.faqs.org/rfcs/rfc3501.html I would suggest you would have to retrieve and store a list of messages, and use that for comparison the next time you fetch.

Upvotes: 0

Related Questions