Answers for "python extract email attachment"

0

python extract email attachment

from imap_tools import MailBox

# get all attachments from INBOX and save them to files
with MailBox('imap.my.ru').login('acc', 'pwd', 'INBOX') as mailbox:
    for msg in mailbox.fetch():
        for att in msg.attachments:
            print(att.filename, att.content_type)
            with open('C:/1/{}'.format(att.filename), 'wb') as f:
                f.write(att.payload)
Posted by: Guest on August-10-2021

Code answers related to "python extract email attachment"

Python Answers by Framework

Browse Popular Code Answers by Language