imaplib Search for Messages by Time
bw
ben.wbr20 at gmail.com
Wed Nov 3 12:47:21 EDT 2010
Hello everyone.
I've been writing a program that interfaces with a user's GMail
account using OAuth, and I'm trying to find a way to search for
messages that were received only after a certain date AND time.
It seems pretty easy to get messages after a certain date. Here's the
relevant code that I have now, which works:
...
imap_conn = imaplib.IMAP4_SSL(imap_hostname)
imap_conn.authenticate('XOAUTH', lambda x: xoauth_string)
imap_conn.select('INBOX')
(typ, data) = imap_conn.search(None, '(SINCE "01-Nov-2010")')
...
But ideally I'd be able to do something like '(SINCE "01-Nov-2010
10:00:00")'.
I know that I can do this locally, but time is a critical factor here
so I'd like to avoid downloading any messages that I don't need.
Thanks!
More information about the Python-list
mailing list