I use the following approach for sending an email in Outlook.
import pandas as pd
import numpy as np
import win32com.client as win32
df = pd.DataFrame(np.array([[1, 2], [4, 5]]), index=('27-04-2020','28-04-2020'), columns=('Prediction', 'Certainty'))
html= df.to_html()
#SEND MAIL
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = '[email protected]'
mail.HTMLBody = html
mail.Subject = "Test"
mail.send
However, I get an error when running the code: pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft Outlook', 'The operation failed.', None, 0, -2147467259), None)
Do any of you have an idea for a solution?