【发布时间】:2020-12-29 08:20:28
【问题描述】:
我正在编写一个脚本,将 pandas 数据框作为表格发送给几个人。我有我的数据框frame:
SITE ... VISITS
438 1 ... 104
439 2 ... 104
440 3 ... 104
504 4 ... 215
我正在尝试创建一个可以使用电子邮件发送的 pretty_html_table:
from pretty_html_table import build_table
html_table = build_table(frame, 'blue_light')
但是,脚本不是通过电子邮件发送表格,而是通过电子邮件发送一堆 html 文本!
<p><table border="0" class="dataframe">
<thead>
<tr style="text-align: right;">
<th style = "background-color: #FFFFFF;font-family: Century Gothic;font-size: medium;color: #305496;text-align: left;border-bottom: 2px solid #305496;padding: 0px 20px 0px 0px">SITE</th>
etcetera, etcetera ...
我正在尝试将此表附加到这样的电子邮件中:
import win32com.client as win32
def report_email(email):
html_table = build_table(frame, 'blue_light')
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = email
mail.Subject = 'Table below'
mail.Body = "Hi, here is a table" + html_table
return mail.Send()
非常感谢您的帮助!
【问题讨论】: