Skip to content Skip to sidebar Skip to footer

Python Emailing Multipart With Body Content

I can't send an e-mail in python with a body as a multipart email. Everything I've tried has resulted in all of the content as attachments, and I can't get the text or html to show

Solution 1:

You need to specify that the parts are alternatives of one another, e.g. the multipart/alternative mime type:

msg = MIMEMultipart('alternative')

The default is mixed; see the email library examples.

Note that to create an email with both attachments and an alternative (HTML / CSS) option you'll need to have a top-level multipart/related container that contains the alternative parts as the first entry.

Post a Comment for "Python Emailing Multipart With Body Content"