searching imap mail folder but excluding one subfolder

K

Kevin F

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top