Hi,
I am trying to send a Multipart email using Python where a plotly table is embedded into the HTML email content; however the table is not displaying in the email. All other content displays fine. My work around is currently to export the table as a PNG file and then read this file into the email, but I am trying to avoid exporting the table. Below is my code:
from plotly.offline import plot
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
import smtplib
plt_table = plot(table, show_link=False, include_plotlyjs=False, output_type='div')
html_string = '''
<html>
<head>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<style>body{ margin:0 100; background:whitesmoke; }</style>
</head>
<body>
<p>Date: '''+exr_mismatches.iloc[0,2].strftime('%Y-%m-%d')+'''</p>
<p>Table: '''+exr_name+'''</p>
<p>Inconsistencies: '''+str(len(exr_mismatches))+'''</p>
<p>Details:</p>
'''+plt_table +'''
</body>
</html>'''
msg = MIMEMultipart()
msg['Subject'] = 'Report'
msg['From'] = 'sender@hotmail.co.uk'
msg['To'] = 'recipient@gmail.com'
msg.attach(MIMEText(html_string, 'html', 'utf-8'))
s = smtplib.SMTP('smtp.office365.com', 587)
s.starttls()
s.login('username','password')
s.send_message(msg)
s.quit()
Any help to get my table to appear would be much appreciated.
Thanks