[python-win32] MAPI Advise Sink

Mark Hammond mhammond at skippinet.com.au
Wed Aug 6 00:49:26 CEST 2008


I'm afraid that the MAPI module doesn't support that interface and its
unlikely you will be able to get it going with an IDispatch based interface.
This interface is very small though, so if you are willing to take a little
messing around I could add that interface and send you a new copy of the
MAPI module - contact me off-line if that interests  you.

 

Cheers,

 

Mark

 

From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org] On Behalf Of Brenda Bell
Sent: Wednesday, 6 August 2008 2:51 AM
To: python-win32 at python.org
Subject: [python-win32] MAPI Advise Sink

 

I'm trying to write a simple program that connects to MAPI and listens for
change events on the contents table for the default receive folder.

 

According to the documentation, PyIMAPITable.Advise takes a
PyIMAPIAdviseSink.  It's unclear as to how I implement an  object that
supports this interface.

 

The IMAPIAdviseSink interface is defined in mapi32.dll, but mapi32.dll does
not contain a type library.  I have been able to implement a Sink class:

 

          IID_IMAPIAdviseSink =
pythoncom.MakeIID('{00020302-0000-0000-C000-000000000046}')

          IID_Sink =
pythoncom.MakeIID('{65C60411-8743-4c0a-863F-757831F8E56B}')

 

          class Sink():

                      _com_interfaces_ = [IID_IMAPIAdviseSink]

                      _reg_progid_ = 'Python.CarboniteMapiAdviseSink'

                      _reg_clsid_ = str(IID_Sink)

                      _public_methods_ = ['OnNotify']

   

          def OnNotify(self, foo, bar):

          print "Notification triggered."

 

I can create an instance as long as I ask for IUnknown:

 

          sink = pythoncom.CoCreateInstance(IID_Sink, None,
pythoncom.CLSCTX_ALL, pythoncom.IID_IUnknown)

 

But if I ask for IID_IMAPIAdviseSink or attempt to pass the IUnknown to
Advise, policy.py fails with "No such interface supported".

 

Can someone point me to a sample or to documentation that will help me
figure out what I'm doing wrong?

 

Thanks.

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20080806/da8135cb/attachment.htm>


More information about the python-win32 mailing list