将表格插入邮件正文



我想在邮件中添加一个表格,但不是作为附件。 额外的要求是用颜色填充一些单元格,但我无法找到解决方案。

您是否尝试将表格添加为 html ?

<table>
<thead>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</thead>
<tbody>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td bgcolor="red">February</td>
<td style="color: hotpink;">$80</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Sum</td>
<td>$180</td>
</tr>
</tfoot>
</table>

主要问题是HTML代码被解释为纯文本,而不是HTML。 所以,这是答案:

import win32com.client as win32
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = 'name@gmail.com'
mail.Subject = 'Tadadada'
mail.HTMLBody = '<h2>Place your HTML here</h2>'
mail.Send()

最新更新