我正在使用带有 python 2.7 的 yagmail 来通过电子邮件发送表格。
yag = yagmail.SMTP(config.SENDER_UNAME, config.SENDER_PW)
recipient="<email>"
subject= "hello"
body="hi"
html_doc="""<!DOCTYPE html><html><head></head><body><TABLE cellpadding="4" border="1" style="border-width:1px;border-style:solid;border-color:#000000;border-collapse:collapse;" >
<COL width="100px">
<COL width="100px">
<COL width="100px">
<TR>
<TH>product</TH>
<TH># orders</TH>
<TH>revenue</TH>
</TR>
<TR>
<TD align="left">Type 1</TD>
<TD align="left">14</TD>
<TD align="left">730.5</TD>
</TR>
<TR>
<TD align="left">Type 2</TD>
<TD align="left">18</TD>
<TD align="left">1759.3</TD>
</TR>
<TR>
<TD align="left">total</TD>
<TD align="left">32</TD>
<TD align="left">2489.8</TD>
</TR>
</TABLE></body></html>"""
result =yag.send(recipient,subject, [body,html_doc],headers={"From":config.SENDER_FROM})
但是在发送的电子邮件中,表格看起来像这样,添加了额外的单元格和行。我怎样才能防止这种情况发生?