Đỗ Huyền Trang
New member
How do you send an email with an attachment in Python?
Answer
In a string, write the body of the message you want to send, namely body. Now, attach the body with the instance msg using
attach function.
…
For adding an attachment, you need to import:
Answer
In a string, write the body of the message you want to send, namely body. Now, attach the body with the instance msg using
attach function.
…
For adding an attachment, you need to import:
- import smtplib.
- mime. multipart import MIMEMultipart.
- mime. text import MIMEText.
- mime. base import MIMEBase.
- from email import encoders.