Build and parse email messages (headers, attachments, MIME).
Intermediate
from email.message import EmailMessage
msg = EmailMessage()
msg["Subject"] = "Report"; msg["To"] = "office@upeec.org"
msg.set_content("Attached."); msg.add_attachment(pdf_bytes, maintype="application", subtype="pdf", filename="r.pdf")
Send it with smtplib.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.