Outlook: detecting if Send event already fired for a MailItem

E

EclecticMonk

We have an Outlook COM add-in built using C++.
In our OnItemSend handler, we do some processing on attachments which we
really only want to happen once. Normally, this is fine: our OnItemSend
fires just before the item is sent.
However, we've encountered a problem where some customers have another
add-in installed as well as ours. This other add-in also handles OnItemSend,
and in some circumstances it sets the Cancel flag to warn the user that there
is a problem that must be resolved before sending the message.
Here's what happens in these cases:
1. User hits the "Send" button
2. Our OnItemSend fires and we process the attachments.
3. The other add-in's OnItemSend fires and it cancels sending the message
4. Once the user has resolved the problem, they hit "Send" again
5. Our OnItemSend fires AGAIN and we process the attachments

Does anyone know of any way that we can detect that it's the second time our
OnItemSend handler has been called for a particular MailItem? The IDispatch
pointer that gets passed into the handler seems to be different every time,
so it doesn't look like we can determine the MailItem's identity that way.

Any guidance would be very much appreciated.

Thanks in advance.
 
D

Dmitry Streblechenko

You could look at the value of the EntryID property. If your code modifies
the message, you could check if the modification had already been done.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO

and MAPI Developer Tool
 
E

EclecticMonk

Dmitry,

Thanks for the quick response. The EntryID property looks very promising;
I'll take a closer look at that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top