Scheduled emails with Python for BI

As part of reporting in business intelligence, scheduled emails are a very useful tool. They allow you to send various daily summaries, or attach larger reports.

For these purposes I put together a Python BI-mailer class to allow for easy management of all things you might normally require to send, such as text, summary/KPI html tables, embedded images or charts, or attach larger reports.

I will put the code here, and in the next articles I will give examples of how to use this easy Python emailer to accomplish daily reporting chores.

With this script you are able to:
send an email
optionally with text or multiple tables in body
optionally with attachments
optionally use the attachments as embedded images.

 

Author: Adrian

I'm a Business intelligence professional working in the tech scene in Berlin, Germany. I'm currently freelancing. If you'd like to check my services, visit adrian.brudaru.com

5 thoughts on “Scheduled emails with Python for BI”

  1. I have discovered few bugs trying to use above mentioned script.
    With following modifications everything works flawlessly. Thanks for the code

    Changing from “alternative” to “mixed”
    msg = MIMEMultipart(‘mixed’)

    Changing the order of attaching mail parts (first body of the mail) and declaring utf-8
    #add html body after attachments
    msg.attach(MIMEText(self.htmlbody, ‘html’, “utf-8”))

    #check if there are attachments if yes, add them
    if self.attachments:
    self.attach(msg)

Leave a Reply

Your email address will not be published. Required fields are marked *