我早上刚起床,突然在正常工作时出现上述错误,如下所示的简单代码打印电子邮件正文内容。
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))