AttributeError: 'NoneType' object has no attribute 'get_payload'

355 views Asked by At

I just woke up in the morning and suddenly get this error as above while it was working perfectly, simple code as below to print the email body contents.

imapObj = imapclient.IMAPClient('outlook.office365.com', ssl=True) # Access IMAP server

imapObj.login('[email protected]', 'PASSWORD') # Credintial logins

imapObj.select_folder('INBOX', readonly=False) 

UIDs = imapObj.search(['FROM' , '[email protected]'])

for i in UIDs:

    data = imapObj.fetch(i, ['BODY[]']) 

    message = pyzmail.PyzMessage.factory(data[i][b'BODY[]'])
    
       
    print(message.text_part.get_payload().decode(message.text_part.charset))
0

There are 0 answers