0

尝试从已发送的项目中获取电子邮件时出现错误,而当我从收件箱中获取电子邮件时它可以正常工作。有人有同样的问题吗?

谢谢你们。


import imapclient, pprint , pyzmail ,re
import socket

out = {}



socket.getaddrinfo('127.0.0.1', 8080)

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

imapObj.login('email', 'pass') # Credintial logins

imapObj.select_folder('Sent Items', readonly=False) # Select inbox folder in IMAP server to search

#pprint.pprint(imapObj.list_folders())

UIDs = imapObj.search(['ALL']) # search from email to reutrn IDs

for i in UIDs:
    

    data = imapObj.fetch(UIDs, ['BODY[]']) #UIDs to the fetch() method to obtain the email content

    message = pyzmail.PyzMessage.factory(data[i][b'BODY[]'])
    
    header = str(message.get_subject())
    
    print(header) 

错误和回溯如下:

Traceback(最近一次调用最后):文件“C:\Users\alaziza\Desktop\Python\sentCCverification.py”,第 24 行,在 data = imapObj.fetch(UIDs, 'RFC822').items() #UIDs 到fetch() 方法获取电子邮件内容文件“C:\Users\alaziza\AppData\Roaming\Python\Python37\site-packages\imapclient\imapclient.py”,第 1367 行,在 fetch typ 中,data = self._imap。 _command_complete("FETCH", tag) 文件 "C:\Users\alaziza\AppData\Local\Programs\Thonny\lib\imaplib.py",第 1027 行,在 _command_complete 中引发 self.error('%s 命令错误:%s %s' % (name, typ, data)) imaplib.IMAP4.error: FETCH command error: BAD [b'Command Error. 10']

4

0 回答 0