Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - how to change email text typeface

Tags:

python

email

I'm writing an app that generates full report and it's summary, and sends them via email. A summary is sent as text in email, and a full report is sent as attachement. I found an example (link) that works great, but I would need to set font's typeface of an email message as monospaced (e.g. 'Courier New').

Any idea how to do this?

Thanks in advance.

like image 570
Ales Kancilija Avatar asked Aug 10 '11 13:08

Ales Kancilija


People also ask

How do you change the font of text in Python?

Open the Python shell. Then, in the menu bar, under "Python" (directly to the right of the Apple icon), you will find "Preferences". Under this, you will find the "Font/Tabs" option, and you can change the font size according to your preference.

How do you change the font in Python HTML?

To change the font style, you need the font-style property with a value of normal , oblique , or italic . Normal is the default font style, so you don't need to specify it unless you have to override it. As usual, you can change the font style in inline, internal, or external CSS.


1 Answers

Email will send as both plaintext and as HTML. A plaintext email renderer will generally be rendered in a monospace font, but there is no guarantee of that. More importantly, there is nothing you can do to change what font the plaintext will display in.

If your recipient is reading mail in an HTML capable email client, you should be able to accomplish that by wrapping <font face="Courier New, Courier, monospace"></font> (a font tag) around the pieces of the email you'd like to have in Courier. In the method provided, you would simply have:

text = '<font face="Courier New, Courier, monospace">' + text + '</font>'

If you wanted that to be the whole email.

like image 195
cwallenpoole Avatar answered Oct 13 '22 21:10

cwallenpoole