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@XYZ.COM', 'PASSWORD') # Credintial logins
imapObj.select_folder('INBOX', readonly=False)
UIDs = imapObj.search(['FROM' , 'EMAIL@XYZ.COM'])
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))