Answer the question
In order to leave comments, you need to log in
How to know if a letter has been read or not (imap)?
M = imaplib.IMAP4_SSL("imap.gmail.com", 993)
M.login(...)
M.select('Inbox', readonly=True)
rv, data = M.search(None, "All")
for num in data[0].split():
box = {}
typ, msg_data = .M.fetch(num, '(RFC822)')
raw_email = msg_data[0][1]
raw_email_string = raw_email.decode('utf-8')
# converts byte literal to string re moving b''
email_message = email.message_from_string(raw_email_string)
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question