Write Outlook add-in / plugin in C#, VB.NET

Add-in Express™
for Microsoft® Office and .net

Add-in Express Home > Add-in Express for Office and .NET > Online Guide > Writing Outlook COM add-ins

How to create Outlook COM add-ins

The example below gives you a step-by-step guidance on developing a version independent COM add-in for Outlook. The plug-in creates two toolbars: for the Outlook Explorer and Inspector windows, the toolbars show up in the UI of pre-Ribbon versions. A custom CommandBar button is added to the toolbars as well as to context menu and the Explorer main menu of Outlook 2007 - 2000. In Outlook 2021 - 2007, a ribbon button is added to the Ribbon UI of the inspector windows. Also, the addin creates an advanced task pane supporting all versions. Finally, a custom property page is added to the Properties dialog of a folder and a keyboard shortcut is intercepted. This sample add-in is written in VB.NET, but you can also write your plug-ins in Visual C# and C++.NET.

You can download the source code of the project as well as plenty more samples on the How-To pages: VB.NET add-in for Outlook and C# addin for Outlook. For more details, please see Outlook add-in development - special features

Step 1. Creating an Outlook add-in project

Make sure that you have administrative permissions before running Visual Studio. Run Visual Studio via the Run as Administrator command.

In Visual Studio, open the New Project dialog and navigate to the Extensibility folder.

Creating a new COM Add-in project

Choose Add-in Express COM Add-in and click OK. The wizard allows choosing your programming language (VB.NET, C# or C++ .NET) and specifying the oldest Office version your plugin needs to support.

Choose your programming language

Let's select VB.NET as our programming language of choice and Office 2010 as the minimum Office version so that our plugin will work in Outlook 2010 and higher. Click Next and choose Outlook as the only targeted application.

Choose Outlook as the only targeted application

On the next step choose whether to generate new or specify an existing .snk file.

Choosing a strong name file

If you don't know anything about strong names or don't have a special strong name key file, choose Generate new. If you are in doubt, choose Generate new. If, later on, you need to use a specific strong name key file, you will be able to specify its name on the Signing tab of your project properties; you are required to unregister your add-in project before using another strong name.

You will find the newly created solution in the IDE.

Creating a new COM add-in project

The solution contains an only project, the COM add-in project. The VB.NET Outlook addin project contains the AddinModule.vb file and a C# project contains AddinModule.cs, discussed in the next step.

Step 2. Add-in module

AddinModule.vb (or AddinModule.cs) is the core part of the project. It is a container for components essential for the functionality of your add-in. You specify the add-on properties in the module's properties, put components onto the module's designer, and write the functional code of your add-in in this module. To review its source code, in the Solution Explorer, right-click AddinModule.vb (or AddinModule.cs) and choose View Code in the popup menu.

Outlook add-in module code

In the code of the module, pay attention to three points:

  • the comment line in the constructor of the module

  • The comment suggests that you write any initialization code in the AddinInitialize or AddinStratupComplete events of the add-in module, not in the constructor. This is important because an instance of the module is created (this runs the constructor) when your plug-in is being registered and unregistered. When the module is created for this purpose, no Office objects, properties, methods or events are available. If your code is not prepared for this, the installer of your add-in will fail.

    Moving custom initialization code out of the module's constructor allows preventing installation failures.
  • the OutlookApp property

  • This property was added by the COM add-in project wizard. You use it as an entry point to the Outlook object model; see Step 11. Accessing Outlook objects.

  • the CurrentInstance property

  • This property returns the current instance of the add-in module, a very useful thing when, for example, you need to access the add-in module from the code of an advanced Outlook region.

Step 3. Add-in module designer

In Solution Explorer, right-click AddinModule.vb (or AddinModule.cs) and choose View Designer in the context menu.

Outlook COM add-in designer

The add-in module designer view provides access to the following three areas:

  • Add-in Express Toolbox - (#1 on the screenshot below) it contains commands; clicking a command creates a new Add-in Express component and places it onto the add-in module
  • Add-in module designer - (#2 on the screenshot below) it is a usual designer
  • In-place designer - (#3 on the screenshot below) if there's a visual designer for the currently selected Add-in Express component, then it is shown in this area
  • Help panel – see #4 in the screenshot below.

The areas are shown in the screenshot below:

COM Add-in module

To put any Add-in Express component onto the module, you click an appropriate command in the Add-in Express Toolbox (#1 in the screenshot above). Then you select the newly added component and set it up using the visual designer (#3 in the screenshot above) and Properties window. Note that the add-in module provides a number of properties. Click the designer surface and specify the name and description of your plug-in in the Properties window. Also, pay attention to the RegisterForAllUsers property – it is essential for distinguishing per-user and per-machine plug-ins; you must unregister the add-in project before modifying this property.

Step 4. Creating a new Outlook Explorer toolbar

To add a toolbar to the Outlook 2000-2007 Explorer window, click the Add ADXOlExplorerCommandBar command in the Add-in Express Toolbox. This places a new ADXOlExplorerCommandBar component onto the add-in module.

Creating a new Explorer toolbar

You may use both Command Bar UI and Ribbon UI components on the add-in module. When your plugin is loaded in a particular version of the host application, either command bar or ribbon controls will show up. Find additional information in Command Bars on the Office Ribbon.

Select the command bar component just created and, in the Properties window, specify the command bar name in the CommandBarName property.

An Outlook Explorer CommandBar component on the add-in module

ADXOlExplorerCommandBar provides context-sensitive properties: they are FolderName, FolderNames, and ItemTypes. The component displays the specified Explorer command bar for every Outlook folder, the name and default item type of which correspond to the values specified in the FolderName, FolderNames, and ItemTypes properties. Note that the FolderName and FolderNames properties require entering the full path to a folder. FolderName also accepts "*" (asterisk), which means "for every folder". This is the only use of the asterisk recognizable in the current version. In other words, Add-in Express does not support template characters in the FolderName(s) properties.

In the screenshot above, you see the properties of the Outlook Explorer command bar that will be shown for every Outlook folder (FolderName = "*") the default item type of which is Mail or Task.

The component creates controls on the toolbar the name of which you specify in the CommandBarName property. If the toolbar is missing in Outlook, the component creates it. That is, if you set CommandBarName = "Standard", and add an ADXCommandBarButton to the Controls collection of the ADXOlExplorerCommandBar component, this will create the button on the built-in Standard toolbar, while specifying CommandBarName = "Standard2" will create a new toolbar, Standard2, with the button on it. If the Standard2 toolbar already exists in Outlook, the button will be added to that toolbar. Use our free Built-in Controls Scanner to get the names of all built-in command bars in any Office 2013-2000 application.

Step 5. Creating a new toolbar button

Select the command bar component on the add-in module designer and open the in-place designer area. In this area, you'll see the visual designer of the ADXOlExplorerCommandBar component. Use its toolbar to add or remove command bar controls.

Command bar component

To add an icon to the button, add an ImageList to the add-in module and specify the ImageList, Image, and ImageTransparentColor properties of the button. Note that the Style property (not shown in the screenshot) is set to adxMsoButtonIconAndCaption in order to show the icon because command bar buttons do not show icons by default. The screenshot below demonstrates button properties that make the image used in the sample project show up as transparent.

Button properties that make the image transparent

See also Command Bar Control Properties and Events.

Step 6. Customizing the Outlook Ribbon user interface

To add a new custom tab to the Ribbon UI, you use the Add ADXRibbonTab command that places a new ADXRibbonTab component onto the module. The ribbons in which that tab will be shown are set by the Ribbons property. For an Outlook plugin, the default value of this property is OutlookMailRead;OutlookMailCompose which means that the tab will be shown in the Mail Inspector windows of Outlook 2007 and higher. In order to show that tab in the Outlook Explorer windows as well, set the Ribbons property to OutlookMailRead;OutlookMailCompose;OutlookExplorer.

Add Ribbon Tab component

You use the visual designer of the ADXRibbonTab component to populate a Ribbon tab with Add-in Express components that form the Ribbon interface of your add-in. In this sample, you add a Ribbon tab component and change its caption to My Ribbon Tab. Then you select the tab component, add a Ribbon group, and change its caption to My Ribbon Group. Finally, you select the group and add a button. Set the button caption to My Ribbon Button. Use the Glyph property to set the image for the button.

Add Ribbon Tab command

See also Office Ribbon components.

Step 7. Creating a new Inspector toolbar

To add a custom toolbar to Outlook 2000-2003 Inspector windows, use the Add ADXOlInspectorCommandBar command that places a new ADXOlInspectorCommandBar component onto the add-in module.

Add Inspector Command Bar component

ADXOlInspectorCommandBar provides the same context-sensitive properties as ADXOlExplorerCommandBar: the properties are FolderName, FolderNames, and ItemTypes. Add-in Express displays the Inspector command bar for every item created or opened in an Outlook folder, the name and default item type of which correspond to the values specified in the FolderName, FolderNames, and ItemTypes properties. Note that the FolderName and FolderNames properties require entering the full path to a folder. FolderName also accepts "*" (asterisk), which means "for every folder". This is the only use of the asterisk recognizable in the current version. In other words, Add-in Express doesn't support template characters in the FolderName(s) properties.

Outlook Inspector command bar component properties

In the screenshot above, you see the properties of the Outlook Inspector command bar that will be shown for every Outlook folder (FolderName = "*") the default item type of which is Mail or Task.

If the toolbar name is the same as the name of a built-in command bar of the host application, then the component will create the controls you specify on the built-in toolbar. Otherwise, the component will create a new toolbar at run time. That is, if you set CommandBarName = "Standard", and add, say, an ADXCommandBarButton to the Controls collection of the ADXOlInspectorCommandBar component, this will create the button on the built-in Standard toolbar, while specifying CommandBarName = "Standard2" will create a new toolbar, Standard2, with the button on it. If the Standard2 toolbar already exists in the host application, the button will be added to that toolbar. Use our free Built-in Controls Scanner to get the names of all built-in command bars in any Office 2000-2010 application.

For adding a new command bar button onto the inspector toolbar see Step 5. Adding a new toolbar button. See also Command Bar UI components.

Step 8. Customizing main menu in Outlook 2000 - 2007

Outlook 2000-2003 provides two main menu types. They are available for two main types of Outlook windows: Explorer and Inspector. Accordingly, Add-in Express Toolbox provides two Outlook-related main menu components: Explorer Main Menu component and Inspector Main Menu component.

The Ribbon UI replaces the main menu of Inspector windows in Outlook 2007 and all main menus in Outlook 2010 and above. Nevertheless, the main menu as well as all command bars and their controls are still available for the developer, please see Navigating up and down the command bar system.

To demonstrate the standard steps required when dealing with built-in CommandBar controls, we will add a custom control to the File | New popup in the Explorer window of Outlook 2000-2007.

You start our free Built-in Control Scanner to scan the command bars and controls of Outlook. The screenshot below shows the result of scanning.

Scanned Office IDs

You need the Office IDs shown in the screenshot to bind Add-in Express components to the corresponding CommandBar controls built in the host application of your add-in.

Now add an Outlook Inspector Main Menu component onto the add-in module and do the following (all values below are taken from the screenshot above):

  • Add a popup control to the menu and set its Id property to 30002
  • Add a popup control to the popup control above and set its Id to 30037
  • Add a button to the popup above and specify its properties. To show your button before the Mail Message button, set its BeforeID property to 1757

The following screenshot shows the settings of the popup created at step 2 above:

Outlook pop-up control settings

See also Connecting to existing commandBar controls.

Step 9. Customizing Outlook context menu

Add-in Express allows customizing commandbar-based context menus of Outlook 2002-2007 via the ADXContextMenu component (Outlook 2000 context menus are not customizable, and Outlook 2013 doesn't support commandbar-based context menus either). Click the corresponding command in the Add-in Express Toolbox to add such a component onto the add-in module. Then choose Outlook in the SupportedApp property of the component. Then, in the CommanBarName property, choose the context menu you want to customize. Finally, you add custom controls using the visual designer of the context menu component.

Context Menu component

The sample Outlook plug-in described on this page adds a custom item to the Folder Context Menu command bar; that is the name of the context menu shown when you right-click a folder in the folder tree.

Adding a custom item to the Folder Context Menu command bar

Context menus in Outlook 2010 are customizable with both ADXContextMenu (commandbar-based) and ADXRibbonContextMenu (Ribbon-based) components. Note that CommandBar-based context menu items cannot be positioned in the Ribbon-based context menus of Outlook 2010: a custom context menu item created with the ADXContextMenu component will always be shown below any built-in or custom context menu items in a Ribbon-based context menu.

Only Ribbon-based context menus are supported in Outlook 2013 - 2021.

The Add ADXRibbonContextMenu command in the Add-in Express Toolbox places a new ADXRibbonContextMenu component onto the add-in module.

Ribbon Context Menu component

Then you set the Ribbons property that supplies context menu names for the ContextMenuNames property of the ADXRibbonContextMenu component. Finally, you use the ContextMenuNames property editor to choose the context menu(s) that will display your custom controls specified in the Controls property.

Adding Ribbon Context Menu component

The screenshot below shows the editor window of the ContextMenuNames property. To get the context menu names displayed in the screenshot, you need to set the Ribbons property to OutlookMailRead;OutlookMailCompose;OutlookExplorer as shown in the screenshot above.

Editor window of the ContextMenuNames property

See also Command Bar UI components and Ribbon UI components.

Step 10. Creating an advanced Outlook region

Creating a new Outlook region includes the following steps:

  • Use the Add-in Express Toolbox to put an Outlook Forms Manager, ADXOlFormsManager, onto the add-in module

  • Outlook Forms Manager component

  • Open the Add New Item dialog in Visual Studio to add an Add-in Express Outlook Form, ADXOlForm, to the project

  • Outlook Forms Manager component

  • Select the Outlook Forms Manager component and add an item to its Items collection

  • Outlook Forms Manager component

The item of the ADXOlFormsCollectionItem type provides properties for showing the form specified in the FormClassName property. For this sample project, the properties and their settings are as follows:

  • FormClassName = MyOutlookAddin1.ADXOlForm1

The class name of the form, instances of which will be created and shown as specified in other properties.

  • ExplorerItemTypes = Mail
  • ExplorerLayout = BottomSubpane

An instance of the form specified in the FormClassName property will be shown below the list of items in the Outlook Explorer whenever you navigate to a mail folder.

  • InspectorItemTypes = Mail
  • InspectorLayout = BottomSubpane

An instance of the form specified in the FormClassName property will be shown below the message body whenever you open an email.

  • AlwaysShowHeader = True
  • CloseButton = True

These will show a header containing the form icon and the form caption even if the form is a single form in the given region. The header will contain the Close button; when you click it, the form will generate the ADXCloseButtonClick event (cancellable).

  • UseOfficeThemeForBackground = True

A pre-defined color corresponding to the current Office theme is used for the background of the form specified in the FormClassName property.

Outlook Forms Manager component

See also Advanced Outlook form and view regions.

Step 11. Accessing Outlook objects

Add the following method to the add-in module:


				Friend Function GetSubject(ByVal InspectorOrExplorer As Object) As String
					Dim item As Object = Nothing
					Dim selection As Outlook.Selection = Nothing

					If TypeOf InspectorOrExplorer Is Outlook.Explorer Then
						Try
							'Explorer.Selection may fire an exception; see below
							selection = CType(InspectorOrExplorer, Outlook.Explorer).Selection
							item = selection.Item(1)
						Catch
						Finally
							If selection IsNot Nothing Then Marshal.ReleaseComObject(selection)
						End Try
					ElseIf TypeOf InspectorOrExplorer Is Outlook.Inspector Then
						Try
							item = CType(InspectorOrExplorer, Outlook.Inspector).CurrentItem
						Catch
						End Try
					End If

					If item Is Nothing Then
						Return ""
					Else
						Dim subject As String = "The subject is:" + "'" + _
							item.GetType().InvokeMember("Subject", _
								Reflection.BindingFlags.GetProperty, _
								Nothing, item, Nothing).ToString() _
							+ "'"
						Marshal.ReleaseComObject(item)
						Return subject
					End If
				End Function
			

The code of the GetSubject method emphasizes the following:

  • Outlook fires an exception when you call the Explorer.Selection property and a certain folder, such as RSS Feeds, is the current folder in the specified Explorer window; the list of such folders depends on the Outlook version loading your add-in.
  • There may be no items selected.
  • All COM objects created in your code must be released, see Releasing COM objects

Now create the following event handlers for the CommandBar and Ribbon buttons added in previous steps:


			Private Sub ActionInExplorer(ByVal sender As System.Object) _
			   Handles AdxCommandBarButton1.Click
				Dim explorer As Outlook.Explorer = Me.OutlookApp.ActiveExplorer
				If explorer IsNot Nothing Then
					MsgBox(GetSubject(explorer))
					Marshal.ReleaseComObject(explorer)
				End If
			End Sub

			Private Sub ActionInInspector(ByVal sender As System.Object) _
					 Handles AdxCommandBarButton2.Click, AdxCommandBarButton6.Click
				Dim inspector As Outlook.Inspector = Me.OutlookApp.ActiveInspector
				If inspector IsNot Nothing Then
					MsgBox(GetSubject(inspector))
					Marshal.ReleaseComObject(inspector)
				End If
			End Sub

			Private Sub AdxRibbonButton1_OnClick(ByVal sender As System.Object, _
				ByVal control As AddinExpress.MSO.IRibbonControl, _
				ByVal pressed As System.Boolean) Handles AdxRibbonButton1.OnClick

				Dim context As Object = control.Context
				If TypeOf context Is Outlook.Inspector Then
					' Outlook 2007 and higher
					ActionInInspector(Nothing)
				ElseIf TypeOf context Is Outlook.Explorer Then
					' Outlook 2010 and higher
					ActionInExplorer(Nothing)
				Else
					' there can be a lot of other contexts in Outlook 2010 - 2021,
					' see http://msdn.microsoft.com/en-us/library/ee692172(office.14).aspx
				End If
				Marshal.ReleaseComObject(context)
			End Sub
			

Step 12. Handling Outlook events

The Add-in Express Toolbox provides the Add Events command that creates (and deletes) event components providing application-level events.

Outlook Events component

In this sample, we place the Outlook Events (ADXOutlookAppEvents) component onto the add-in module.

With the Outlook Events component, you handle application-level events of Outlook. For instance, the following code handles the BeforeFolderSwitch event of the Outlook.Explorer class:


			  Private Sub adxOutlookEvents_ExplorerBeforeFolderSwitch (ByVal sender As Object, _
			   ByVal e As AddinExpress.MSO.ADXOlExplorerBeforeFolderSwitchEventArgs) _
			   Handles adxOutlookEvents.ExplorerBeforeFolderSwitch
			   MsgBox("You are switching to the " + e.NewFolder.Name + " folder")
			End Sub
            

If you create a label on the form added in Step 10. Creating an advanced Outlook region, you can modify the label in the ADXSelectionChange event of the form:


			Private Sub ADXOlForm1_ADXSelectionChange() Handles MyBase.ADXSelectionChange
				Me.Label1.Text = CType(Me.AddinModule, MyOutlookAddin1.AddinModule) _
					.GetSubject(Me.ExplorerObj)
			End Sub
              

See also Step 13. Handling events of the Outlook Items object and Events classes.

Step 13. Handling events of Outlook Items object

The Outlook MAPIFolder class provides the Items collection. This collection provides the following events: ItemAdd, ItemChange, and ItemRemove. To process these events, you use the Outlook Items Events Class item located in the Add New Item dialog.

Adding Outlook Items Event class

This adds the OutlookItemsEventsClass1.vb class to the add-in project. You handle the ItemAdd event by entering some code into the ItemAdd method of the class:


			Imports System

			'Add-in Express Outlook Items Events Class
			Public Class OutlookItemsEventsClass1
			   Inherits AddinExpress.MSO.ADXOutlookItemsEvents

			   Public Sub New(ByVal ADXModule As AddinExpress.MSO.ADXAddinModule)
				  MyBase.New(ADXModule)
			   End Sub

			   Public Overrides Sub ItemAdd(ByVal Item As Object)
				  MsgBox("The item with subject '" + Item.Subject + _
					 "' has been added to the Inbox folder")
			   End Sub

			   Public Overrides Sub ItemChange(ByVal Item As Object)
				  'TODO: Add some code
			   End Sub

			   Public Overrides Sub ItemRemove()
				  'TODO: Add some code
			   End Sub
			End Class
			
			

To use this class, you have to add the following declarations and code to the add-in module:


			Dim ItemsEvents As OutlookItemsEventsClass1 = _
				   New OutlookItemsEventsClass1(Me)

			Private Sub AddinModule_AddinBeginShutdown(ByVal sender As Object, _
				  ByVal e As System.EventArgs) Handles Me.AddinBeginShutdown
			   If ItemsEvents IsNot Nothing Then
				  ItemsEvents.RemoveConnection()
				  ItemsEvents = Nothing
			   End If
			End Sub

			Private Sub AddinModule_AddinStartupComplete(ByVal sender As Object, _ 
				  ByVal e As System.EventArgs) Handles Me.AddinStartupComplete
			   ItemsEvents.ConnectTo( _
					 AddinExpress.MSO.ADXOlDefaultFolders.olFolderInbox, True)
			End Sub
			   

To process events of the Folders and Items classes as well as of all sorts of Outlook items, see Event classes.

See also Outlook Item Events explained and Outlook Items and Folders Events explained.

Step 14. Adding property pages to the folder properties dialog

Outlook allows adding custom pages (tabs) to the Options dialog (the Tools | Options menu) as well as to the Properties dialog of any folder. To automate this task, Add-in Express provides the ADXOlPropertyPage component. You find it in the Add New Item dialog (see the screenshot below).

Adding Outlook property page

Click the Add button to add a descendant of the ADXOlPropertyPage class to your project. You can customize that page as an ordinary form: add controls and handle their events.

To add a property page to the <folder name> Properties dialog box of an Outlook folder(s), you do the following:

  • In the add-in module properties, run the editor of the FolderPages property
  • Click the Add button
  • Specify the folder you need in the FolderName property
  • Set the PageType property to the property page component you've added
  • Specify the Title property and close the dialog box.

The screenshot below shows the settings you need to display your page in the Folder Properties dialog for the Inbox folder.

Outlook property page properties

The path to the Inbox folder depends on the environment as well as on the Outlook localization. To take care of this, get the path to the Inbox folder at plug-in startup and assign it to the FolderName property of the Folder Page item. The code below gets the full folder name of the Inbox folder in the AddinStartupComplete event of the add-in module:


			   Private Sub AddinModule_AddinStartupComplete(ByVal sender As Object, _
					 ByVal e As System.EventArgs) Handles Me.AddinStartupComplete
			   ItemsEvents.ConnectTo( _
				  AddinExpress.MSO.ADXOlDefaultFolders.olFolderInbox, True)
			   Dim ns As Outlook.NameSpace = Me.OutlookApp.GetNamespace("Mapi")
			   Dim folder As Outlook.MAPIFolder = _
				  ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
			   Me.FolderPages.Item(0).FolderName = GetFolderPath(folder)
			   Marshal.ReleaseComObject(folder)
			   Marshal.ReleaseComObject(ns)
			End Sub
			
			

See the code of the GetFolderPath function in FolderPath property is missing in Outlook 2000 and XP.

Now add a check box to the property page. The code below handles the CheckedChanged event of the check box as well as the Dirty, Apply, and Load events of the property page:


				...
				Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
				Private TrackStatusChanges As Boolean

				...

				Private Sub CheckBox1_CheckedChanged( _
				ByVal sender As System.Object, _
				ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
					If Not TrackStatusChanges Then _
						Me.OnStatusChange() 'this enables the Apply button
				End Sub

				Private Sub PropertyPage1_Dirty( _
				ByVal sender As System.Object, _
				ByVal e As AddinExpress.MSO.ADXDirtyEventArgs) Handles MyBase.Dirty
					e.Dirty = True
				End Sub

				Private Sub PropertyPage1_Apply( _
				ByVal sender As System.Object, _
				ByVal e As System.EventArgs) Handles MyBase.Apply
					CType(AddinModule.CurrentInstance, MyOutlookAddin1.AddinModule) _
						.IsFolderTracked = Me.CheckBox1.Checked
				End Sub

				Private Sub PropertyPage1_Load( _
				ByVal sender As Object, _
				ByVal e As System.EventArgs) Handles Me.Load
					TrackStatusChanges = True
					Me.CheckBox1.Checked = _
						CType(AddinModule.CurrentInstance, MyOutlookAddin1.AddinModule) _
							.IsFolderTracked
					TrackStatusChanges = False
				End Sub
				

Finally, you add the following property to the add-in module:


				Friend Property IsFolderTracked() As Boolean
				   Get
					  Return ItemsEvents.IsConnected
				   End Get
				   Set(ByVal value As Boolean)
					  If value Then
						 ItemsEvents.ConnectTo(ADXOlDefaultFolders.olFolderInbox, True)
					  Else
						 ItemsEvents.RemoveConnection()
					  End If
				   End Set
				End Property
			

This sample project demonstrates adding a property page to the Folder Properties dialog of a given Outlook folder. To add a property page to the Tools | Options dialog box (Outlook 2000 - 2007), you use the PageType and PageTitle properties of the add-in module. In Outlook 2010 and higher, you open that dialog via File Tab | Options | Add-ins | Add-in Options.

See also Outlook Property page.

Step 15. Intercepting keyboard shortcuts

To intercept a keyboard shortcut, you use the Add Keyboard Shortcut command that puts an ADXKeyboardShortcut onto the add-in module. Choose or enter a key combination in the ShortcutText property of the component and handle its OnAction event .

Keyboard Shortcut component properties

Intercepting keyboard shortcuts requires that you set the HandleShortcuts property of AddinModule to true.


			   Private Sub AdxKeyboardShortcut1_Action(ByVal sender As System.Object) _
				  Handles AdxKeyboardShortcut1.Action
				  MsgBox("You've pressed " + _
					 CType(sender, AddinExpress.MSO.ADXKeyboardShortcut).ShortcutText)
			   End Sub
			

Step 16. Running Outlook add-in

Choose Register Add-in Express Project in the Build menu. Alternatively, you can choose Add-in Express | Register in the context menu of your add-in project. See also If you use an Express edition of Visual Studio.

Start the host application(s) and check if the add-in works. If the add-in isn't visible in the host application's UI, see Troubleshooting add-in loading.

Registering Add-in Express Project

The new plug-in in the Outlook Explorer window:

The add-in is run in the Outlook Explorer window

The new plug-in in the Outlook Inspector window:

The add-in is run in the Outlook Inspector window

You can find your plug-in in the COM Add-ins dialog.

Step 17. Debugging your Outlook plug-in

To debug your add-in, just specify the Outlook executable in Start External Program in the Project Options window and press F5.

Debugging Outlook add-in

Step 18. Deploying your Outlook plugin

The table below provides links to step-by-step instructions for deploying COM add-ins. Find background information in Deploying Office extensions.

Table 2. Deploying COM add-ins: links to step-by-step instructions

How you install the Office extension

Per-user COM add-in
Installs and registers for the user running the installer

Per-machine COM add-in
Installs and registers for all users on the PC

A user runs the installer from a CD/DVD, hard disk or local network location. Windows Installer
ClickOnce
ClickTwice :)
Windows Installer
ClickTwice :)
A corporate admin uses Group Policy to install your Office extension for a specific group of users in the corporate network; the installation and registration occurs when a user logs on to the domain. For details, please see the following article on our blog: HowTo: Install a COM add-in automatically using Windows Server Group Policy. Windows Installer N/A
A user runs the installer by navigating to a web location or by clicking a link. ClickOnce
ClickTwice :)
ClickTwice :)

What's next?

You may check the following sections under Add-in Express tips and notes: