Christian Takutsirk on Mon, 04 Jun 2018 12:43:01
On a fresh windows 10 system with office 2016 none of the following methods works to get a MAPI session from python:
from win32com.client import Dispatch o = Dispatch('Outlook.Application') o.GetNamespace('MAPI').Session.MAPIOBJECT.QueryInterface(mapi.IID_IMAPISession)
from win32com.mapi import mapi mapi.MAPIInitialize((0,mapi.MAPI_MULTITHREAD_NOTIFICATIONS))
Both fail (on the last line) with an error message
pywintypes.com_error: (-2147467259, 'Unknown error', None, None)
Additionally a window opens saying that the standard mail application is not defined. I checked in the system preferences and switched the default mail app from the windows 10 Mail app to Outlook but the error remains.
Any ideas how to debug that?
Thanks you in advance, Christian
Dmitry Streblechenko _MVP_ on Mon, 04 Jun 2018 16:56:51
It means the library you are using loads a wrong MAPI dll. You need to load msmapi32.dll
Christian Takutsirk on Tue, 05 Jun 2018 01:49:31
Thanks for the hint, this made me search in the right place. The answer is pretty simple: I tried to access 32 bit Outlook from 64 bit python. Sorry for the noise.
Terry Xu - MSFT on Tue, 05 Jun 2018 02:40:28
Hello Christian Takutsirk,
Glad to hear that your issue has been resolved. I would suggest you mark the helpful reply or your solution to close the thread. If you have any other issue, please feel free to post threads to let us know.