searching imap mail folder but excluding one subfolder

Kevin F neurogasm at gmail.com
Thu Mar 23 02:54:54 EST 2006


I have code that searches under the default folder (inbox) but I would 
like to modify it to search for everything in that folder with the 
exception of one subfolder where I would like it not to search.

my current code is:


from imaplib import *
import getpass

server = IMAP4("webmail.xxxxx.xxxx.edu")

server.login('username', getpass.getpass())

r = server.select("Inbox")

r, data = server.search(None, 'SUBJECT', 'WALLET ENLARGEMENT')
for num in data[0].split():
    server.store(num, '+FLAGS', '\\Deleted')
server.expunge()


how do i modify it so that, for example, it searches in inbox but does 
not search in a specific subfolder 'opim' under inbox?



More information about the Python-list mailing list