简体   繁体   中英

Python MIMEText formatting

I'm sending emails via python using MIMEText.

A crude short example:

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

What if I want TODAY to be italicized and/or bolded in the email?

MIMEText supports html format. You can do this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM