File: email_from_eml.py

package info (click to toggle)
imap-tools 1.10.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,624 kB
  • sloc: python: 4,709; makefile: 5
file content (8 lines) | stat: -rw-r--r-- 285 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
from imap_tools import MailMessage

with open('.../attachment_2_base64.eml', 'rb') as f:
    bytes_data = f.read()
msg = MailMessage.from_bytes(bytes_data)
print(msg.date_str, msg.subject)
for i, att in msg.attachments:
    print('-', att.filename, att.content_type, len(att.payload))