imaplib Search for Messages by Time

Discussion in 'Python' started by bw, Nov 3, 2010.

  1. bw

    bw Guest

    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!
    bw, Nov 3, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. Magoo
    Replies:
    0
    Views:
    373
    Mr. Magoo
    Sep 1, 2003
  2. Raghul
    Replies:
    1
    Views:
    607
    Kartic
    Feb 23, 2005
  3. Tony Meyer
    Replies:
    1
    Views:
    429
    Raghul
    Feb 23, 2005
  4. Tony Meyer
    Replies:
    1
    Views:
    587
    Raghul
    Feb 24, 2005
  5. Replies:
    2
    Views:
    591
Loading...

Share This Page