By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,035 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,035 IT Pros & Developers. It's quick & easy.

search mail by date with imaplib

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.