Friday, January 2, 2015

New Year Greetings to all contacts

New Year Greetings to all contacts


As 2014 ended, I figured it was a good time to send out a New Year's Greeting to all of my professional contacts. But, with over a thousand contacts on LinkedIn alone, it would have been a several days of work to compose an email individually. It should be possible to download all of the LinkedIn contacts and then script a custom email to every one.

Step 1: Export LinkedIn contacts 

From LinkedIn Connections, select "Manage Sources" (accessed via the gear icon on the connections page). At the top right, there is a link to export contacts.

https://www.linkedin.com/contacts/manage_sources/ page
Export the CSV file.

Step 2: Script to send a custom email to every contact

Really any scripting language could be used, but, I chose Python since I am not using it daily. Like any skills,  I need to practice to keep the skill sharp.  I wrote this quick script which worked on CentOS, presuming that email is properly configured. Should also work on any Linux variant.

#!/usr/bin/env python26
import csv
import smtplib
import time

sender='
myemail@domain.com'

message="""From: myemail@domain.com
Return-path: myemail@domain.com
Reply-to: myemail@domain.com
To: {0} {1} <{2}>
Subject: Hi {0}, Happy New Year 2015

Dear {0}, Greetings!

Message you want to send.

Happy New Year 2015.
Signature

 """

# CSV Format: FirstName,LastName,Email
f = open('data.csv', 'r')
try:
    reader = csv.reader(f)
    for row in reader:
      print row[2] 
      if row[2] != "":  # data.csv may be missing an email address
        msg=message.format(row[0], row[1], row[2])
        server = smtplib.SMTP('localhost')
        server.sendmail(sender, row[2], msg)
        server.quit()
        time.sleep(10)  # Meter your messages. SMTP relays block messages if too many are sent quickly.
finally:
    f.close()


For a thousand contacts, this script will run for about 3 hours sending one email every 10 seconds. 

If you run this script, I suggest wrapping it in a nohup command. 

Step 3: Read replies and respond to them.

Just because you are able to send bulk New Year greeting emails, it does not absolve your responsibility to actually communicate with your connections. If I get a response from my connection, I respond and follow up!

1 comment:

  1. I had neglected to meter the messages, so only about half of my contacts got the email. The other half didn't ... (Sorry, didn't mean to ignore you)

    ReplyDelete