Email and MIME Modules
email.mime.text
Creates legacy text MIME parts with a subtype and character encoding. MIMEText chooses ASCII for ASCII-only text or UTF-8 otherwise when no charset is supplied. The transfer encoding is determined by the charset; prefer EmailMessage.set_content for new code.
Formal Syntax & Structure
python syntaxpython
import email.mime.textReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from email.mime.text import MIMETextpart = MIMEText("café", _charset="utf-8")print(part.get_payload(decode=True).decode(part.get_content_charset()))