Here is my code:
import imaplib
from email.parser import HeaderParser
conn = imaplib.IMAP4_SSL('imap.gmail.com')
conn.login('[email protected]', 'password')
conn.select()
conn.search(None, 'ALL')
data = conn.fetch('1', '(BODY[HEADER])')
header_data = data[1][0][1].decode('utf-8')
at this point I get the error message
AttributeError: 'str' object has no attribute 'decode'
Python 3 doesn't have decode anymore, am I right? how can I fix this?
Also, in:
data = conn.fetch('1', '(BODY[HEADER])')
I am selecting only the 1st email. How do I select all?