📌  相关文章
📜  python 提取电子邮件附件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:34.007000             🧑  作者: Mango

代码示例1
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)