I am implementing COM Add-In for Outlook. I use IDTExtensibility2. I am not sure whether this is the best way of doing COM Add-Ins but I cannot change that.
This interface defines five methods: OnConnection, OnStartupComplete, OnAddInsUpdate, OnBeginShutdown, OnDisconnection.
I need to perform the following operations:
Please advise, what I am supposed to do when?
Note that 1,2 and 6 are not Outlook-addin-specific tasks.
3 is not needed: As an addin you don't create a session - you get connected with an existing one (by implementing the OnConnection
method).
For 4 and 9 I recommend using RDO: http://dimastr.com/redemption/ (can also be used for 3 if you really need another session)
For 5,7 and 8 I recommend using ADX: http://www.add-in-express.com/add-in-net/
(you won't actually have to worry about IDTExtensibility2
at all anymore if you do this)
OnConnection
is where you grab your reference to the Application
interface from which you can derive everything else.
OnStartupComplete
is where you can put all your initialization code.
OnDisconnection
is where you should release all remaining OOM references you may have accumulated during the session, i.e everything that was derived from the initial Application
reference that you received via OnConnection
.