Verifying whether an Inspector item is valid after a send

Add-in Express™ Support Service
That's what is more important than anything else

Verifying whether an Inspector item is valid after a send
Accessing Inspector.CurrentItem in ADXOutlookAppEvents.InspectorClose 
Martin Bayly




Posts: 41
Joined: 2007-10-05
OL2007
ADX 3.8 1886.2005

This is probably an Outlook issue rather than an ADX issue but wondered if someone here could help?

We're using ADXOutlookAppEvents to handle ItemSend and InspectorClose events.

InspectorClose seems to get called:
1. If you just close an open inspector by closing the Inspector window
2. If you send the message in the open inspector. In this case ItemSend is called followed by InspectorClose.

We have code in InspectorClose that interrogates properties of the inspector's current item.


_Inspector olInsp = inspector as _Inspector;
MailItem mi = olInsp.CurrentItem as MailItem;
if (mi != null)
{
    string subject = mi.Subject; // throws exception after Send
}


In the scenario where the inspector has just been closed this code works fine. However, when it's called after an ItemSend, it seems like any attempt to access properties of the CurrentItem results in a

System.Runtime.InteropServices.COMException (0x8004010A): The item has been moved or deleted.


Of course we can just catch and ignore the exception. Or possibly we could store something in our ItemSend handler so that we could skip this code after a send (assuming events are sent in order which I don't want to rely on).

Anyone know of a way to test if the item is valid without throwing exceptions?

Thanks
Martin
Posted 01 Apr, 2008 16:18:51 Top
Sergey Grischenko


Add-in Express team


Posts: 7224
Joined: 2004-07-05
Hi Martin.

I would advise you to use ADXOutlookItemEvents class to make the changes in the inspector item. Please see the OutlookItemEvents example from the Add-in Express installation package.
Posted 02 Apr, 2008 07:13:44 Top