Email and MIME Modules
email.mime.multipart
Creates legacy multipart MIME containers with ordered child parts. The default subtype is mixed; alternative represents alternative versions of the same content. A boundary separates parts in serialized form and may be generated automatically during serialization.
Formal Syntax & Structure
python syntaxpython
import email.mime.multipartReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from email.mime.multipart import MIMEMultipartfrom email.mime.text import MIMETextmessage = MIMEMultipart("alternative")message.attach(MIMEText("hello"))message.attach(MIMEText("<p>hello</p>", "html"))print(len(message.get_payload()), message.get_content_type())