I am trying to send an e-mail using import smtplib. And I want it to render the html and send it in an e-mail. Unfortunately it currently just sends the html code in the e-mail. Any suggestion would be much appreciated.
My Code is below:
import smtplib
import pandas as pd
DEFAULT_EMAIL_SERVER = "x"
TO = ["[email protected]"]
FROM = "[email protected]"
SUBJECT = "TEST"
table = pd.read_excel('abc.xlsm')
body = '<html><body>' + table.to_html() + '</body></html>'
TEXT = body
message = """From: %s\r\nTo: %s\r\nSubject: %s\r\n\
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
server = smtplib.SMTP(x)
server.sendmail(FROM, TO, message)
server.quit()