tags:

views:

21

answers:

1

I'm using http://ruby-doc.org/stdlib/libdoc/net/imap/rdoc/index.html to access gmail.

I can search for emails with a particular label, but I'm trying to avoid to search an email twice.

So in order to do that, I thought that I could store the message_id of each email so that in the next searches I would reefer to that message_id to avoid searching for that email.

Do you know how can I do to search emails that are not part of a given email message_id list?

Thanks a lot for your time!

+1  A: 

Rather than storing message ids, why don't you just search after a certain message date (which would be the date of your last search)?

dave wanta
Wow, believe me or not, I finally did what you suggested :).I'm saving the newest reception date of all the emails that I download, and then use that date to search through IMAP. # We select the folder on read only access. imap.examine(folder) # Search all the email that are not deleted and return them in the emails collection. keys = ["NOT", "DELETED"] keys = keys + ["SINCE", last_downloaded_email_date.strftime("%d-%b-%Y")] if last_downloaded_email_date imap.uid_search(keys)Thanks a lot for your answer :)
ClaudioA