【发布时间】:2021-06-03 08:00:16
【问题描述】:
我正在尝试使用呈现 html 的 exchangelib 发送电子邮件。
下面是我的邮件功能和正文
def send_email(account, subject, body, recipients):
"""
>>> send_email(account, 'Subject line', 'Hello!', ['info@example.com'])
"""
to_recipients = []
for recipient in recipients:
to_recipients.append(Mailbox(email_address=recipient))
# Create message
m = Message(account=account,
folder=account.sent,
subject=subject,
body=body,
to_recipients=to_recipients)
m.send_and_save()
"""
<hr>
<table class=3D"x_data_table" style=3D"margin:0px auto;border-collapse:coll=
apse;width:800px;display:inline">
<thead>
<tr>
<th style=3D"border-bottom:2px solid rgb(17, 29, 51)">Item</th>
<th style=3D"border-bottom:2px solid rgb(17, 29, 51)">Created</th>
<th style=3D"border-bottom:2px solid rgb(17, 29, 51)">Created By</th>
</tr>
</thead>
<tbody>
<tr class=3D"x_odd" style=3D"background-color:rgb(245, 245, 245)">
<td class=3D"x_table_long_text" style=3D"border:1px solid rgb(191, 194, 201=
)">I hate myself and want to die</td>
<td class=3D"x_table_numerical" style=3D"border:1px solid rgb(191, 194, 201=
)">2021-02-23 17:08:48</td>
<td class=3D"x_table_text" style=3D"border:1px solid rgb(191, 194, 201)">cb=
eard22</td>
</tr>
<tr class=3D"x_even" style=3D"background-color:rgb(212, 220, 224)">
<td class=3D"x_table_long_text" style=3D"border:1px solid rgb(191, 194, 201=
)">Happy Tuesday</td>
<td class=3D"x_table_numerical" style=3D"border:1px solid rgb(191, 194, 201=
)">2021-02-23 18:32:35</td>
<td class=3D"x_table_text" style=3D"border:1px solid rgb(191, 194, 201)">sm=
porter2</td>
</tr>
</tbody>
</table>
"""
当我发送它时,它会作为常规文本加载。我试图让它呈现为普通的 html,以便它像网页一样显示在电子邮件中。我怎样才能将此呈现为 html
【问题讨论】:
标签: python-3.x email outlook exchangelib