[python-win32] OnItemSend cancel help
Mark Hammond
mhammond at skippinet.com.au
Fri Nov 10 00:01:15 CET 2006
In general, you should simply return the value of that variable. You didn't
include the next line of the makepy snippet which includes the types, but a
possibility is that the event handler is actually a function rather than a
"sub" - so maybe something like:
return 0, True
should be used - returning 0 for the function itself, with the True being
for cancel.
Wish I could be more help...
Mark
-----Original Message-----
From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org]On Behalf Of d tiu
Sent: Friday, 10 November 2006 7:15 AM
To: python-win32 at python.org
Subject: [python-win32] OnItemSend cancel help
Hi all,
I'm writing an outlook addin, trying to stop email sends on certain
conditions. I'm using OnItemSend callbacks that has a cancel
parameter which if set to True, will cancel the send. It's not
working :(. I'm calling:
self.applicationEvents = DispatchWithEvents(application,
ApplicationEvent)
with
class ApplicationEvent:
def OnItemSend(self, item, cancel):
print "OnItemSend"
cancel = True
and desperate, also tried:
class ApplicationEvent:
def OnItemSend(self, item, cancel):
print "OnItemSend"
cancel = True
return cancel
I've confirmed that the handler is getting called, but the cancel
parameter seems like it's not getting back to outlook.
The makepy has
# def OnItemSend(self, Item=defaultNamedNotOptArg,
Cancel=defaultNamedNotOptArg):
as the prototype on gen_py\ApplicationEvents.py.
Any ideas? One thing is that the VB call is
Sub object_ItemSend(ByVal Item As Object, Cancel As Boolean)
which I suspect Cancel is passed by reference? If so, is this handled
by the mechanisms in DispathWithEvents? If not, how does one do it?
Thanks
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20061110/edc975e9/attachment.html
More information about the Python-win32
mailing list