How mutt check to download emails from an imap server without downloading them more than once?
Peng Yu
pengyu.ut at gmail.com
Sun Mar 19 14:52:33 UTC 2023
Hi,
I use the following python code to download UNDELETED messages. But it
will fetch all messages without considering whether an message has
been downloaded previously. How does mutt solve this problem to only
download the emails that have not been downloaded before.
import email
with IMAPClient(host=host) as client:
client.login(user, passwd)
client.select_folder('INBOX', readonly=True) # preserve the \Recent flag.
messages = client.search(search_criteria) # UNDELETED
response = client.fetch(messages, ['RFC822'])
for message_id, data in response.items():
with open('%s/%d.eml' % (outdir, message_id), 'wb') as f:
f.write(data[b'RFC822'])
--
Regards,
Peng
More information about the Mutt-users
mailing list