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 str.decode() anymore, so how can I fix this?