import imaplib
usr = 'someuser'
pwd = 'somepwd'
imap_server = imaplib.IMAP4_SSL('imap.gmail.com', 993)
imap_server.login(USER, PASSWORD)
imap_server.select('Inbox')
for message_id in imap_server.search(None, '(FROM "example email.com")')[1][0].split(" "):
response = imap_server.fetch(message_id, "RFC822.TEXT")
print response[1][0][1]
I want to search for email with a certain subject and from email address. How do I adjust this code to fit incorporate both check?
Also, once i open a message, I want to search the message for certain content. What is the best way to go about this? Thanks!