[python-win32] MAPI with win32com

Werner F. Bruhin werner.bruhin at free.fr
Mon Mar 22 12:22:29 CET 2010


On 22/03/2010 12:06, Werner F. Bruhin wrote:
> I am trying to use MAPI to send an email using win32com, but I get the
> following exception.
>
> from win32com.client import Dispatch
> s = Dispatch("Mapi.Session")
> Traceback (most recent call last):
> File "<input>", line 1, in <module>
> File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line
> 95, in Dispatch
> dispatch, userName =
> dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
> 98, in _GetGoodDispatchAndUserName
> return (_GetGoodDispatch(IDispatch, clsctx), userName)
> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line
> 78, in _GetGoodDispatch
> IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> pythoncom.IID_IDispatch)
> com_error: (-2147221005, 'Cha\xeene de classe incorrecte', None, None)
>
> I first tried this having Thunderbird as my MAPI client, then installed
> Windows Live Email (I want to test MAPI with one of the "newer" MS Mail
> clients) and defined it as the MAPI client (Default Programs - MAPI),
> still same result.
>
> Any hints on what I am doing wrong here would be very much welcomed.
>
> I am on Windows 7, Python 2.5.4, py2in32 build 210.
>
> Werner
Just came accross Tim Golden's site 
(http://timgolden.me.uk/python/win32_how_do_i/read-my-outlook-inbox.html) and 
tried this:

session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")

But I do get the same exception.

Werner




More information about the python-win32 mailing list