Outlook Addin: OutlookItemEventsClass

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

Outlook Addin: OutlookItemEventsClass
Accessing public properties from AddinModule 
David Wisniewski




Posts: 39
Joined: 2015-11-20
In the AddinModule.vb there are two built-in public properties defined: CurrentInstance and OutlookApp

    Public Shared Shadows ReadOnly Property CurrentInstance() As AddinModule
        Get
            Return CType(AddinExpress.MSO.ADXAddinModule.CurrentInstance, AddinModule)
        End Get
    End Property

    Public ReadOnly Property OutlookApp() As Outlook._Application
        Get
            Return CType(HostApplication, Outlook._Application)
        End Get
    End Property


In my OutlookItemEventsClass I need to reference things that require the use of these properties from the AddinModule. To reduce code, I've simplified referencing these items by declaring them as class level objects in the OutlookItemEventsClass.vb like this:

    Private ThisAddin As OutlookMacrosV2.AddinModule = OutlookMacrosV2.AddinModule.CurrentInstance
    Private OutlookApp As Outlook._Application = ThisAddin.OutlookApp


Does this cause any known memory issues, or an issue with com objects not being released, as the OutlookItemEvents class is connected very frequently. If so, is there a different way that the ItemEvents class should be accessing the two properties from the AddinModule?
Posted 06 Dec, 2021 03:55:31 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello David,

This is okay to use the Application object when you need it. Other ways may not be that suitable: say, there's the Module property on the event classes; it returns and you would need to cast it to your project's AddinModule.

Regards from Poland (CET),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Dec, 2021 09:59:59 Top