Python-如何更改电子邮件文本字体 [英] Python - how to change email text typeface
问题描述
我正在编写一个可生成完整报告及其摘要并通过电子邮件发送报告的应用。
摘要以电子邮件中的文本形式发送,完整的报告以附件形式发送。
我找到了一个很好的示例(链接),但我需要将电子邮件的字体设置为等宽字体(例如 Courier New)。
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?
预先感谢。
推荐答案
电子邮件将以纯文本和HTML形式发送。纯文本电子邮件渲染器通常将以等宽字体呈现,但不能保证这一点。更重要的是,您无法更改明文将以哪种字体显示。
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.
如果收件人正在使用支持HTML的电子邮件客户端中阅读邮件,则应该可以通过将< font face = Courier New,Courier,monospace>< / font>
(字体标签)包裹在电子邮件的各个部分来实现此目的您想在快递中使用。在提供的方法中,您只需要:
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.
这篇关于Python-如何更改电子邮件文本字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!