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