Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 606
chompion Avatar asked Feb 13 '23 18:02

chompion


1 Answers

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')
like image 118
venpa Avatar answered Feb 17 '23 03:02

venpa