I am using the below code to send email with an attachment using python. I using the outlook application itselt(not via backend)
from time import sleep
import win32com.client as win32
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = "EMAIL ADDRESS"
mail.Subject = "Subject"
mail.HtmlBody = "HTML Body"
mail.Attachments.Add("folderName\\output.zip")
mail.Display(True)
sleep(1)
mail.Send()
Its working fine till the line mail.Display(True). I can see the outlook new mail window open with everything typed in and also file attached. But the next statement mail.send() is giving error :
Traceback (most recent call last): File "C:/Users/username/PycharmProjects/001.PySelenium/win32email.py", line 16, in <module>
mail.send() File "C:\Users\username\PycharmProjects\001.PySelenium\venv\lib\site-packages\win32com\client\dynamic.py", line 516, in __getattr__
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1) pywintypes.com_error: (-2147467260, 'Operation aborted', None, None)