im trying to query in mailbox with python3 imap_tools , cant uderstand how to extract emails with sender email and unseen flag. Trying like this
for msg in [msg for msg in mailbox.fetch(Q(from_=sender, seen=False))]
And always get same error
imap_tools.utils.UnexpectedCommandStatusError: Response status for command "box.search" == "NO", "OK" expected, data: [b'[CANNOT] Unsupported search criterion: FROM "ZOYA1608@YANDEX.RU" UNSEEN']
Can somebody explain where my mistake, full code below
with open("..\\conf\\conf.yaml", mode="r") as stream:
for conf in yaml.safe_load_all(stream):
with MailBox(conf['host']).login(conf['mailbox'], conf['password']) as mailbox:
for sender in conf['senders']['from']:
for msg in [msg for msg in mailbox.fetch(Q(from_=sender, seen=False))]:
for att in msg.attachments:
with open(get_path(file_name=att.filename, store_paths=conf['store_paths']), 'w+b') as f:
f.write(att.payload)
Most likely: your server doesn't fully support the IMAP search specification.
Regards, imap_tools author.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.