Automate and schedule sending of e-mail using python
Published in
3 min readDec 5, 2020
The aim of this article is to explain how we can use our personnal or professional e-mail address to automate and schedule sending e-mails using python.
I. Create and send e-mail using python
First Step : Import python packages
####################################################################
############# Import packages
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText# to create html template for the email content
from string import Template# if we want include images
import base64
Second step : Create the email content
Create your email template using html and css :
####################################################################
############# Build the email content using html
##################################################################### Import image
img_uri = base64.b64encode(open('path/img.png', 'rb').
read()).decode('utf-8')
img_tag = '<img src="data:image/png;base64 {0}">'.format(img_uri)# Html email contents
message = """
<!DOCTYPE html>
<html>
<head>
<title>Hello World !</title>
</head>
<div style="position: relative; top: 20px; left: 30px;">
"""+img_tag+"""
</div>…