win32com.client.Dispatch("Outlook.Application") error pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

Ansuman Bebarta picture Ansuman Bebarta · Jan 2, 2013 · Viewed 15.8k times · Source

I am on windows 7 and I have windows live installed. Now when I am trying to run following code

import win32com.client
win32com.client.Dispatch("Outlook.Application")

I am getting following error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in
Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,c

    lsctx)
      File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 108, in
    _GetGoodDispatchAndUserName
        return (_GetGoodDispatch(IDispatch, clsctx), userName)
      File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 85, in _
    GetGoodDispatch
        IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.II
    D_IDispatch)
    pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

I have another machine with windows xp and Outlook installed. I ran the same code and I got the same error.

One more question. How can I get the com of windows live on windows 7?

Any suggestions and comments will be appreciated.

Answer

Dmitry Streblechenko picture Dmitry Streblechenko · Mar 23, 2015

This is an indication that Outlook is not installed. "windows live" or "outlook.com" would not help you.