[python-win32] automating outlook using python

Rasuka Kishore rasukakishore at gmail.com
Fri May 27 13:03:04 CEST 2011


i am trying to automate outlook using python. my code seems to work fine
with outlook 2007, however with outlook 2003 it's giving the following
error.

Traceback (most recent call last):
 File "<stdin>",line 1, in <module>
 File "C:\Python27\lib\site-packages\comtypes\client\_events.py", line 218
in ShowEvents
return comtypes.client.GetEvents(source, sink=EventDumper(),
interface=interface)
 File "C:\Python27\lib\site-packages\comtypes\client\_events.py", line
193,in GetEvents
 interface = FindOutgoingInterface(source)
 File "C:\Python27\lib\site-packages\comtypes\client\_events.py", line 73 in
FindOutgoingInterface
 raise TypeError("cannot determine source interface")
TypeError: cannot determine source interface

This is the code i am using

from comtypes.client import GetEvents
class EventSink(object):
    def ApplicationEvents_11_NewMailEx(self, this, entryid):
        print "mail arrived"
        print entryid
    def ApplicationEvents_10_NewMailEx(self, this, entryid):
        print "mail arrived"
        print entryid

from comtypes.client import CreateObject
xl = CreateObject("Outlook.Application")
from comtypes.client import PumpEvents
sink = EventSink()
connection = GetEvents(xl, sink)
PumpEvents(3000)

can anyone plz point out as to what could be possibly wrong.
Thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20110527/45ad649d/attachment.html>


More information about the python-win32 mailing list