Last active
August 29, 2015 13:56
-
-
Save Jwpe/8947705 to your computer and use it in GitHub Desktop.
A simple email personalization script in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First, we construct a list of 'dictionaries', each one a set of information | |
# about a single lead | |
leads = [ | |
{'first_name': 'Paul', 'last_name': 'McCartney', 'company': 'Beatles Inc.', | |
'title': 'Chief Marketing Officer'}, | |
{'first_name': 'Nina', 'last_name': 'Simone' , 'company': 'Jazz & Soul', | |
'title': 'CEO' }, | |
{'first_name': 'Michael', 'last_name': 'Jagger', | |
'company': 'Rolling Stone Corp', 'title': 'SVP Marketing'}, | |
] | |
# Next, we set up the script for our email, with placeholders for the info | |
# that we wish to insert for each lead | |
email_content = """ | |
Dear {first_name}, | |
How's it going? I'm reaching out to you in your role as {title} at {company} | |
to gauge your interest in checking out a free 30-day trial of our software. | |
I think {company} could really benefit from the advantages our tool provides. | |
Kind regards, | |
Jon Evans | |
""" | |
# Finally, we use a 'for loop' to iterate through our leads, creating a | |
# customized email for each by inserting our dictionary data into our generic | |
for lead in leads: | |
print email_content.format( | |
first_name=lead['first_name'], | |
title=lead['title'], | |
company=lead['company']) | |
# To run this script, we would make sure Python was installed on our PC, | |
# then in our command prompt, write 'python email_generator.py' when in | |
# the same directory as the file. Et voila! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment