Why did this script didn't work? I've tested on gmail.com, IMAP, mail.ru, yandex.ru IMAPs.
from imap_tools import MailBox, AND, A
mb = MailBox('imap.gmail.com').login('email', 'password')
messages = mb.fetch(criteria=A(AND(seen=False), AND(date=current_date)),
mark_seen=False,
bulk=False)
for msg in messages:
print(msg)
Out: imap_tools.errors.MailboxSearchError: Response status "OK" expected, but "NO" received. Data: [b'[CANNOT] Unsupported search criterion: (UNSEEN) ON 27-JUL-2021']
Thx!
simpler: A(seen=False, date=current_date)
if same error: means that your server can not do it
Code below works on my gmail acc:
for msg in mailbox.fetch(A(seen=True, date=datetime.date(2020, 4, 22))):
print(msg.date, msg.from_)