Alani
Alani

Reputation: 73

imaplib.IMAP4.error: FETCH command error: BAD [b'Command Error. 10']

I get an error when trying to fetch emails from sent items while it works perfectly when I fetch emails from INBOX. Anyone has the same issue?

thank you all.


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) 

Error and traceback as below :

Traceback (most recent call last): File "C:\Users\alaziza\Desktop\Python\sentCCverification.py", line 24, in data = imapObj.fetch(UIDs, 'RFC822').items() #UIDs to the fetch() method to obtain the email content File "C:\Users\alaziza\AppData\Roaming\Python\Python37\site-packages\imapclient\imapclient.py", line 1367, in fetch typ, data = self._imap._command_complete("FETCH", tag) File "C:\Users\alaziza\AppData\Local\Programs\Thonny\lib\imaplib.py", line 1027, in _command_complete raise self.error('%s command error: %s %s' % (name, typ, data)) imaplib.IMAP4.error: FETCH command error: BAD [b'Command Error. 10']

Upvotes: 0

Views: 980

Answers (0)

Related Questions