Hi Malt,
Here is the code
import win32com.client as win32
Outlook = win32.Dispatch('Outlook.application')
mail = Outlook.CreateItem(0)
mail.To = '[email protected]'
mail.Subject = 'python test'
mail.Body = 'test'
mail.HTMLBody = '<h2>HTML Message body</h2>'
mail.Send()
When I run tis script I am getting below error
Error:
Traceback (most recent call last):
File "C:\Users\Sri\PycharmProjects\PythonCoding\venv\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Sri/PycharmProjects/PythonCoding/venv/Test.py", line 3, in <module>
Outlook = win32.Dispatch('Outlook.application')
File "C:\Users\Sri\PycharmProjects\PythonCoding\venv\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Users\Sri\PycharmProjects\PythonCoding\venv\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Users\Sri\PycharmProjects\PythonCoding\venv\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2146959355, 'Server execution failed', None, None)