Answers for "imaplib.error: FETCH command error: BAD [b'Could not parse command'"

0

imaplib.error: FETCH command error: BAD [b'Could not parse command'

import imaplib
import email

m = imaplib.IMAP4_SSL("imap.gmail.com", 993)
m.login("[email protected]","mypassword")
m.select('"[Gmail]/All Mail"')

result, data = m.uid('search', None, "ALL") # search all email and return uids
if result == 'OK':
    for num in data[0].split():
    result, data = m.uid('fetch', num, '(RFC822)')
    if result == 'OK':
        email_message = email.message_from_bytes(data[0][1])    # raw email text including headers
        print('From:' + email_message['From'])

m.close()
m.logout()
Posted by: Guest on August-16-2020

Code answers related to "imaplib.error: FETCH command error: BAD [b'Could not parse command'"

Browse Popular Code Answers by Language