Reading EmailMessage from file

Jon Ribbens jon+usenet at unequivocal.eu
Sun Jul 15 19:34:12 EDT 2018


On 2018-07-15, Skip Montanaro <skip.montanaro at gmail.com> wrote:
> I have an email message in a file (see attached).

Attachments don't work here.

> something like this should construct an email message from the file:
>
>>>> from email.message import EmailMessage
>>>> msg = EmailMessage()
>>>> fp = open("/home/skip/tmp/79487694")
>>>> msg.set_content(fp.read())

What are you actually trying to do? You're talking like you're trying
to read an existing RFC822 email-with-headers from a file, but you're
showing code that creates a new email with body content set from
a file, which is a completely different thing.



More information about the Python-list mailing list