Removing an Outlook Add-in

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

Removing an Outlook Add-in
The best way 
David Alison


Guest


OK, I have an add-in working fine. It actually is just a COM automation shell for my application, loading the app behind the scenes, using two command buttons to call features in the app, etc.

The problem is that if the user unregisters the add-in, the command bar remains. I found that if I set the individual buttons to be temporary, they are eliminated when the add-in is unregistered. If I set the command bar temporary property to True it is also removed - this is the behavior I am looking to achieve.

Unfortunately when setting the temporary property of the command bar to true, it's position is not maintained from session to session within Outlook. If I set the temporary property to false, the empty command bar remains after the add-in is unregistered.

My question is, in the OnBeforeAddinUnregister event, is it possible to delete the command bar? Is there another way I can achieve the results I am looking for? (Specifically, I want the command bar position to be persistent from session to session, yet if the user removes the add-in, I want that command bar to disappear from Outlook).

Thanks in advance for the help!

--David
Posted 16 Mar, 2005 17:04:19 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi David,

What component do you use as a command bar? TadxOLExplorerCommandBar or TadxCommandBar?



Posted 17 Mar, 2005 07:04:16 Top
Guest


Guest


I am using TadxCommandBar.
Posted 17 Mar, 2005 08:12:00 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi David,

Set Temporary property to True (the command bar and all its controls). To save and restore the command bar position see howtos #17:
http://www.add-in-express.com/support/addin-delphi.php


Posted 17 Mar, 2005 08:41:44 Top
David Alison


Guest


Thanks Dmitry. Should I be sing TadxOLExplorerCommandBar instead of TAdxCommandBar? My command bar is not context sensitive within Outlook.
Posted 17 Mar, 2005 09:09:23 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi David,

You can use the TadxOLExplorerCommandBar component with ItemTypes := [adxOLMailItem, adxOLAppointmentItem, adxOLContactItem, adxOLTaskItem, adxOLJournalItem, adxOLNoteItem, adxOLPostItem, adxOLDistributionListItem].

BTW, in the next ADX build we are planning to add the save/restore command bar position feature for the TadxOLExplorerCommandBar component.


Posted 17 Mar, 2005 10:52:50 Top
Carlos Jimenez


Guest


Hi!

I need to handle Tasks when I send them from Outlook, but I dont now how.
I already handle Mails. Here the CODE to do that.
Can I manage the Tasks in the same procedure "Enviar"?

Thanks in advance for the help!

-- Carlos


*** CODE ***

type
TPrueba_Outlook = class(TadxAddin, IPrueba_Outlook)
end;

TAddInModule = class(TadxCOMAddInModule)
procedure adxCOMAddInModuleAddInInitialize(Sender: TObject);
procedure adxCOMAddInModuleAddInFinalize(Sender: TObject);
procedure ExplorerCommandbarControls0Click(Sender: TObject);
private
procedure ProcesarElemento(Tipo: String; const Item: IDispatch);
procedure Enviar(ASender: TObject; const Item: IDispatch; var Cancel: WordBool);
procedure Recibir(Sender: TObject);
procedure Iniciar(Sender: TObject);
public
Recibido: Boolean;
end;

...

procedure TAddInModule.adxCOMAddInModuleAddInInitialize(Sender: TObject);
begin

(* Application handle *)
Application.Handle:=GetActiveWindow;

(* Outlook events *)
OutlookApp.OnItemSend:=Enviar;
OutlookApp.OnNewMail:=Recibir;
OutlookApp.OnStartup:=Iniciar;

end;

...

procedure TAddInModule.Enviar(ASender: TObject; const Item: IDispatch; var Cancel: WordBool);
var
Mail: MailItem;
begin
if Assigned(Item) then begin
Item.QueryInterface(IID__MailItem, Mail);
ProcesarElemento('Correo', Item);
end;
end;

...

procedure TAddInModule.adxCOMAddInModuleAddInFinalize(Sender: TObject);
begin
OutlookApp.OnItemSend:=Nil;
OutlookApp.OnNewMail:=Nil;
OutlookApp.OnStartup:=Nil;
end;
Posted 15 Apr, 2005 14:16:39 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Carlos,

See the answer in this topic:
http://www.add-in-express.com/forum/read.php?FID=1&TID=371

Posted 16 Apr, 2005 04:39:23 Top