469,336 Members | 5,570 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

search mail by date with imaplib

Hi
I am looking for a code sample which searches mail by date with imaplib

example:
get email from 01.01.2007 to now

how can I change imaplib search parameters?

Jan 6 '07 #1
1 3990
cs****@gmail.com wrote:
Hi
I am looking for a code sample which searches mail by date with imaplib

example:
get email from 01.01.2007 to now

how can I change imaplib search parameters?
So I had to do the same thing a few years back. I love python but
seriously every author spends less than 1/10 of 1% on doc !

Well So do I .. so take it with a grain of salt. Here is what I did,
MANY YEARS AGO .. I don't even have a IMAP account anymore

t,data = M.uid("SEARCH",None,'(FROM blahblah)')
luid = string.split(data[0])
for uid in luid:
t,d = M.uid("FETCH",uid,"(BODY[HEADER.FIELDS (DATE SUBJECT TO)])")
date = d[0][1]

This will get you the dates .. and you can write your own
filter off that .. it's trivial. What isn't so great is
getting every piece of mail and then searching for the needle's in
the haystack.

So I guess this is plan c (just in case you don't get a better answer).
I will watch this one for a "plan a | b" answer.
Jan 6 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Colin Brown | last post: by
reply views Thread by Wolfgang Kohnen | last post: by
reply views Thread by Luis Corrales | last post: by
reply views Thread by Laszlo Nagy | last post: by
2 posts views Thread by Roopesh | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.