I have a HTML file which is essentially a table. However some of the cells in the table are highlighted and when I convert my HTML file to text as specified in other stackoverflow answers, the coloring of the cells and other CSS specifications disappear in the mail.
Code :
import smtplib
import csv
from tabulate import tabulate
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
text = open("final.html", 'r').read()
message = MIMEMultipart(
"alternative", None, [MIMEText(text), MIMEText(text,'html')])
server = smtplib.SMTP('smtp.gmail.com', 25)
server.connect("smtp.gmail.com",25)
server.ehlo()
server.starttls()
server.ehlo()
server.login('mail', "password")
server.sendmail('from_mail', 'to_mail', message.as_string())
server.quit()
Finally, the message is converted to string as in message.as_string()
. I guess when the message is converted to a string, the CSS formatting options are taken away.
HTML input file :
Any help would be appreciated. Thanks a lot !