Python MIME 文本格式

标签 python email formatting

我正在使用 MIMEText 通过 python 发送电子邮件。

一个粗略的例子:

        message = MIMEText('Hi,\n\nYour taxes are due.\n\nTODAY.\n\nBest,\n\nIRS.')

如果我希望“今天”在电子邮件中显示为斜体和/或粗体怎么办?

最佳答案

MIMEText 支持 html 格式。你可以这样做:

message="""\
    <html>
        <head></head>
        <body>
            <b>"""This is bold"""</b>
            <i>"""This is italic"""</i>
        </body>
    </html>
    """
MIMEText(message,'html')

关于Python MIME 文本格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21889046/

相关文章:

python - 关于幅度的语法错误

python - key 错误 : Django Losing Session Data Between CBV Redirects

email - TFS服务器2015 : Email alerts not working

php - AWS-SES 打开/点击跟踪

python - Geopandas 安装

css - outlook.com 如何将 css 定位到特定类

git - git log 格式的可选缩进换行符

C# Interop Excel format like Excel's format as table

eclipse - 格式化代码块中的代码

python - 如何计算 SQL 行并使用 FLASK 将其存储在变量中,而不总是得到 1 作为答案?