微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

imaplib.IMAP4.error: FETCH 命令错误: BAD [b'Command Error 10']

如何解决imaplib.IMAP4.error: FETCH 命令错误: BAD [b'Command Error 10']

我在尝试从已发送的项目中获取电子邮件时遇到错误,而当我从 INBox获取电子邮件时它运行良好。 有人有同样的问题吗?

谢谢大家。


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) 

错误和回溯如下:

回溯(最近一次调用最后一次): 文件“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 raise self.error('%s 命令错误%s %s' % (name,typ,data)) imaplib.IMAP4.error: FETCH 命令错误: BAD [b'Command Error。 10']

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。