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.



_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to