0

I'd like to change the font size of a specific word in an email I'm sending using python. This is the code I have so far...

import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login("user@gmail.com", "password")
SUBJECT = "The subject"
TEXT = "I would like to change THIS word to bold"
message = 'Subject: {}\n\n{}'.format(SUBJECT, TEXT)
server.sendmail("user@gmail.com", recipients, message)
server.quit()

Is there any way I can change the word "THIS" in the text line to bold (and bigger font), but keep the other words the original font?

Thanks!!!!

Djaenike
  • 1,645
  • 5
  • 21
  • 32
  • 1
    Possible duplicate of [Python - how to change email text typeface](https://stackoverflow.com/questions/7011992/python-how-to-change-email-text-typeface) – Greg Van Aken Aug 17 '18 at 17:17
  • 1
    ...and the next question as to *how* is answered in [Sending HTML email using Python](https://stackoverflow.com/questions/882712/sending-html-email-using-python). – Andrew Morton Aug 17 '18 at 17:33

1 Answers1

0

1.

You can use this code to start bold: \033[1m and this to end it: \033[0m.

E.g. str = "normal " + '\033[1m' + "bold " + '\033[0m' + "normal".

This answer may help you: print bold text in Python

2.

Try this using HTML formatting. It is quite simple. In fact you need only the HTML tag to format words in bold.

However the first method works on my machine.

CFV
  • 740
  • 7
  • 26