[python-win32] Outlook Addin Help

billburns at pennswoods.net billburns at pennswoods.net
Thu May 11 19:24:17 CEST 2006


[Bill]
I've created an addin derived from the example in the ..\win32com\demos
directory (outlookAddin.py). I've also taken a look at the source code
for the SpamBayes addin.

The addin works, but I get an error from Outlook when I close Outlook
and then *immediately* try and restart it. The error from Outlook
is "The operation failed."

[Mark]
Outlook is fairly complicated ;)  Depending on how it is configured, a
mapisp32.exe, responsible for mail delivery, does hang around a few seconds
after outlook terminates, and I recall problems restarting Outlook in this
period even without a plugin loaded.

Thus, I'm afraid I don't believe this is specific to Python (ie, I've no
idea! :)  If some evidence does convince me otherwise, I'd then start
looking at what pythoncom._GetGatewayCount() and/or _GetInterfaceCount()
returns as the plugin terminates and ensure they are both zero before
looking deeper (spambayes has never managed zero here - IIRC it is the
gateway count that is always 2).


[Bill]
I've changed "OnDisconnection()" to look like this,

def OnDisconnection(self, mode, custom):
        self.application = None
        self.activeExplorer = None
        print "Gateway Count: ", pythoncom._GetGatewayCount()
        print "Interface Count: ", pythoncom._GetInterfaceCount()

and the Trace Collector output is,

Object with win32trace dispatcher created (object=None)
Gateway Count:  2
Interface Count:  4

Is there something I should try to get the Interface Count down to zero?

Mark,

You've pushed me in the right direction -> the interface count. I've done some
digging and I'm getting closer :-) I've gone from a count of 4 down to 2. I
guess I need to make sure that I'm releasing certain objects within the addin.

I added a Close() method to the ButtonEvent which sets self.application and
self.activeExplorer to None.

I'll keep at it and work on it later tonight.

Thanks again,

Bill


More information about the Python-win32 mailing list