Outlook - InspectorActivate - CurrentItem

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

Outlook - InspectorActivate - CurrentItem
When trying to receive the CurrentItem on InspectorActivate, Outlook crashes 
Ralf Garbe




Posts: 18
Joined: 2014-11-22
Hello,
when running the following code on Outlook 2010, Outlook crashes.
when debugging it with the SHOWMESSAGE('0') line, all works well.
Could you help me on what I do wrong and how it could be improved.

Thanks,
Ralf
_______________________________

procedure TAddInModule.adxOutlookAppEvents1InspectorActivate(Sender: TObject);
var
IDsp: IDispatch;
Mail: MailItem;
begin
//showMessage('0');
try
IDsp := OutlookApp.ActiveInspector.CurrentItem;
except
end;
if Assigned(IDsp) then
try
IDsp.QueryInterface(IID__MailItem, Mail);
if Assigned(Mail) then begin
mail.Subject := 'setting the subject';
end;
finally
IDsp := nil;
end;
end;
Posted 15 May, 2016 18:11:59 Top
Andrei Smolin


Add-in Express team


Posts: 14138
Joined: 2006-05-11
Hello Ralf,

Add-in Express passes an Outlook2000.TInspector to this event procedure. You can use this fact to retrive the inspector being activated. Currently, you retrieve the active inspector; it looks like Outlook may fire the Activate event on an inspector first and set that inspector as active then.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 17 May, 2016 07:06:44 Top