I have a simple function creating an Outlook email and I’m trying to pass a Dataframe to the body.
def __Emailer(table1, table2, subject, recipient, folder, name, auto=True):
import win32com.client as win32
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = recipient
mail.Subject = subject
mail.HtmlBody = table1 + '<br>' + table2
if auto:
mail.SaveAs('S:/MAILS/{}/{}'.format(folder,name))
else:
mail.open
Then I’m trying to pass my df like this:
__Emailer(df1[:10].to_html(index = False, justify = 'center', bold_rows = True), df2[:2].to_html(), 'e', 'e', 'FOLDER', 'message.msg')
The code was working correctly, but then I tried to modify the table using Styler, which didn’t work, so I reverted back to the simple to_html() method, however now the borders seems to have dissapeared and the whole table is a mess (columns not alligned etc.). I’ve restarted the kernel thinking maybe I’ve set some general html display settings, but it didn’t help. I tried using to_html(border = 1)
but it doesn’t change anything. It’s weird, because index = False
is working fine, however bold_rows = True
doesn’t. The code doesn’t return any errors.
Pandas version: 2.0.3