[python-win32] MAPI with win32com

Werner F. Bruhin werner.bruhin at free.fr
Mon Mar 22 13:40:52 CET 2010


Tim,

Thanks for the quick response.

On 22/03/2010 12:26, Tim Golden wrote:
> On 22/03/2010 11:22, Werner F. Bruhin wrote:
>> 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.
>
> Have a look at:
>
> http://kb.mozillazine.org/MAPI_Support
>
> which explains that TB (like OE) only supports "Simple MAPI". There's
> a whole confusion of terminology around this area, but I'm afraid that
> the bottom line is: the only client which really supports CDO, ie
> MAPI.Session
> is the full Outlook client. It's just about possible to use CDO without
> installing Outlook (by installing some standalone package whose name
> escapes me)
I found this:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E17E7F31-079A-43A9-BFF2-0A110307611E&displaylang=en

At least I get past the above error, will see how far I get with this.
  but that still only gives you access to Exchange, not to
> whatever interface TB exposes.
Clients and me using TB are fine, I support that with the simplemapi.py 
(http://www.johnnypops.demon.co.uk/python/simplemapi.py) and it works 
fine, but clients who use Outlook (e.g. Office 11) get a MAPI error 2 
(failure).
>
> TJG

I don't want to use Outlook, but I like to provide an additional way of 
sending problem reports from within my application to me (MAPI, 
smtplib), so hoped that I could use extended MAPI stuff.

I guess I just have to get my hands onto an Outlook to be able to test 
this stuff.


Werner



More information about the python-win32 mailing list