com_error:(-2147221005,'无效的类字符串',无,无)

问题描述 投票:0回答:1

我正在尝试使用Python连接到Outlook,但以下行引发com_error

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")

完整的回溯如下:

    ---------------------------------------------------------------------------
com_error                                 Traceback (most recent call last)
c:\users\dipf5\appdata\local\programs\python\python37\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch, clsctx)
     88                 try:
---> 89                         IDispatch = pythoncom.connect(IDispatch)
     90                 except pythoncom.ole_error:

com_error: (-2147221005, 'Invalid class string', None, None)

During handling of the above exception, another exception occurred:

com_error                                 Traceback (most recent call last)
<ipython-input-15-a96a5314c4a3> in <module>
----> 1 outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")

c:\users\dipf5\appdata\local\programs\python\python37\lib\site-packages\win32com\client\__init__.py in Dispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx)
     93   """
     94   assert UnicodeToString is None, "this is deprecated and will go away"
---> 95   dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
     96   return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
     97 

c:\users\dipf5\appdata\local\programs\python\python37\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatchAndUserName(IDispatch, userName, clsctx)
    112         else:
    113                 userName = str(userName)
--> 114         return (_GetGoodDispatch(IDispatch, clsctx), userName)
    115 
    116 def _GetDescInvokeType(entry, invoke_type):

c:\users\dipf5\appdata\local\programs\python\python37\lib\site-packages\win32com\client\dynamic.py in _GetGoodDispatch(IDispatch, clsctx)
     89                         IDispatch = pythoncom.connect(IDispatch)
     90                 except pythoncom.ole_error:
---> 91                         IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
     92         else:
     93                 # may already be a wrapped class.

com_error: (-2147221005, 'Invalid class string', None, None)

任何建议都会有帮助。

python outlook com mapi
1个回答
0
投票

看起来像Outlook,在系统上找不到。注意,在运行代码之前,您需要安装Outlook。

© www.soinside.com 2019 - 2024. All rights reserved.