Mailgun API (Python3/C#)

At The Children’s Campaign, we are using a program called Mailgun to send out massive amounts of emails using an API. During the sending process, we assign four separate tags to the emails: LrgEm##, LrgEm##a, LrgEm##b, and LrgEm##c. About a week after we send out these emails through the API, we download all of the 500k logs of events that the email has accumulate (opened, clicked, etc.). Previously we had to consolidate all four tags manually and write excel formulas to do calculations on them, among other steps. It was a sort of tedious process. I thought that we could save time by automating the entire process, so I created this first file (logs.py). It consolidates all of the tags and programmatically adds data into the cells that used to require manual entry of excel formulas. It also uses user entry to name the excel file. All the user has to enter is the tag, type, and date the email was sent out. The program also displays details to the user during runtime.

logs.py

Screen Shot 2017-11-12 at 10.26.22 PMScreen Shot 2017-11-12 at 10.25.59 PMScreen Shot 2017-11-11 at 1.21.56 AM

The second file gets detailed statistics for an email the user specifies, and all the user has to enter is the first tag: LrgEm92.

statistics.py

Screen Shot 2017-11-11 at 2.43.12 PMScreen Shot 2017-11-11 at 2.43.32 PMScreen Shot 2017-11-11 at 2.43.40 PM

The third gets a record of the permanent failures so that they can be deleted from the messaging lists. These include permanent bounces, unsubscribes, and permanent complaints. Three excel files are created for the lists. These are important because they can later be uploaded in order to delete these contacts from the email lists.

failures.py

Screen Shot 2017-11-12 at 10.46.16 PMScreen Shot 2017-11-10 at 7.08.36 PM

View the code for these python files on GitHub.

I also updated a program written in C# from a previous intern, it uses Windows Forms and provides a graphical interface for users to send out emails with. The problem with this program at the time was that it could not schedule emails for delivery, it sent them out immediately when the user pressed send. I used C# to convert a user-specified date and time into a date that was RFC2822 compatible. The user also can select whether or not they would like to schedule the email.

unnamed

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s