[python-win32] MAPI with win32com

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


Hi Malcolm,

On 22/03/2010 14:10, python at bdurham.com wrote:
> Werner,
>
> I'm not sure I understand the benefit of being locked into the
> proprietary and awkward MAPI protocol?
>
> Why can't you use industry standard SMTP to send your messages? Simpler
> and more portable.
I already offer the SMTP option, i.e. there are two buttons, one is 
using smtplib and the other uses MAPI.

As Simon pointed out some users don't like that a message is sent where 
they don't see what is being sent (they actually do in my case as I show 
the details of the error and on that dialog they click one of the two 
buttons).

Werner
>
> Malcolm
>
>
> ----- Original message -----
> From: "Werner F. Bruhin"<werner.bruhin at free.fr>
> To: python-win32 at python.org
> Date: Mon, 22 Mar 2010 13:40:52 +0100
> Subject: Re: [python-win32] MAPI with win32com
>
> 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
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32




More information about the python-win32 mailing list