Search code examples
pythonemailtext

Can python format the emails it sends?


I have a script that runs at evening, it writes to a log file as it runs, and once the task completes, the text it writes is also emailed to me. Sometimes the task can fail, what I want to happen is when I get the email, the line with the error is red and bold.

So my question is, can Python format text to a certain font or color if certain conditions are met? If so, are there any good examples?

Thanks!


Solution

  • I think you could just add html tags to your email and send it as HTML. However it'll change the content of your text file as it'll write additional characters to change the styling.

    EXAMPLE: Sending HTML email using Python