Do it yourself

When I worked at Kenvue, the data science team frequently had to send alert emails to other teams. The problem is that email html specs are all over the place, and data scientist have neither the time or the expertise to manually build emails.

The solution I came up with was a small python library to generate html and plain text emails, featuring images, tables and matplotlib charts.

Simple components, like headings and paragraphs can be appended to the email object.

import emailbuilder as eb

# Create eb.EMail object
email = eb.EMail(
    "EMail Subject",
    "sender@example.com",
    "receiver@example.com"
)

email.append(eb.Header("Hello World!"))
email.append(eb.Paragraph("Lorem ipsum dolor sit amet consectetur"))

Tables can be generated from Pandas data frames:

df = pd.DataFrame({
    'Name': ['Alice', 'Bob'],
    'Age': [25, 30]
})

table = pd.to_dict(orient='dict')

email.append(eb.Table(table))

Matplotlib charts can be embedded:

plt.figure()
plt.plot([1, 2])
plt.title("y = x")

email.append(eb.Figure(plt.gcf(), "A chart for the formula y = x."))

Both images and charts can have an alt text.

More information can be found in the github repo.