Nilani Algiriyage Nilani Algiriyage - 2 years ago 1529
HTML Question

Send pandas dataframe data as html e-mail

I want to send a pandas dataframe data as an HTML e-mail. Based on this post I could create an html with the dataframe. Code

import pandas as pd
import numpy as np

HEADER = '''

FOOTER = '''

df = pd.DataFrame([[1.1, 1.1, 1.1, 2.6, 2.5, 3.4,2.6,2.6,3.4,3.4,2.6,1.1,1.1,3.3], list('AAABBBBABCBDDD')]).T
with open('test.html', 'w') as f:

Now I want to send this as a html e-mail. I tried this. Can not figure out how to attach the html file?

Answer Source

Finally found. This is the way it should be done.

filename = "test.html"
f = file(filename)
attachment = MIMEText(,'html')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download