January 2019
Beginner
318 pages
8h 23m
English
In this section, we're going to see how we can send multimedia content as an attachment and how we can add HTML content. To do this, we'll use the Python email package.
First, we'll see how we can add HTML content. For that, create a script, add_html_content.py, and write the following content in it:
import osimport smtplibfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipartimport getpasshost_name = 'smtp.gmail.com'port = 465sender = 'sender_emailid'password = getpass.getpass()receiver = 'receiver_emailid'text = MIMEMultipart()text['Subject'] = 'Test HTML Content'text['From'] = sendertext['To'] = receivermsg = """\<html> <body> <p>Hello there, <br> Good day !!<br> <a href="http://www.imdb.com">Home</a> ...
Read now
Unlock full access