i am simply trying to send an email to someone whatever is stored in dataframe and when i run the script it ends with process finished with exit code 0 but i see nothing in my sent items.Earlier it was working fine not sure what has gotten into it.
import pandas as pd
from sqlalchemy.engine import create_engine
import datetime
from plyer import notification
import win32com.client as win32
today = datetime.date.today()
df = pd.read_sql(sql = query, con = engine)
if df.shape[0] == 0:
print('No result!!!')
else:
olApp = win32.Dispatch('outlook.application')
#olNS = olApp.GetNameSpace('MAPI')
mailItem = olApp.CreateItem(0)
Body ='''\
<html>
<head></head>
<body>
<p>Please find below the setups for the day.<br>
<body>''' df.to_html() '''</br></body>
<font color = "blue">
<br>Thanks</br>
</font>
<br></br>
<br></br>
<br></br>
<font color="black">
Please note this is an automated mail<t1>
</font>
</p>
</body>
</style>
</html>'''
mailItem.Subject = "Setup report: " " " str(today.strftime('%d-%b-%y'))
mailItem.To = '[email protected]'
[email protected]'
mailItem.HTMLBody = Body
From = '[email protected]'
mailItem.Send
CodePudding user response:
I believe you are just missing the empty brackets at the Send()
method call on the last row.
mailItem.Send()