How to write Outlook COM add-in / plugin in VB.NET, C#, C++.
Create ribbon tabs, menus, buttons for Outlook toolbar.

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

Developing Outlook COM add-ins

The example below gives you a step-by-step guidance on developing a COM add-in for Outlook 2000 - 2010. The add-in creates two toolbars: for the Outlook Explorer toolbar and Inspector windows. A custom CommandBar button is added to the toolbars as well as to context menu and the Explorer main menu of Outlook 2000-2007. In the Outlook 2007-2010 Inspector, a Ribbon button is added to the Ribbon UI. Also, the add-in creates an advanced task pane supporting versions 2000-2010 of the host applications. Finally, a custom property page is added to the Properties dialog of an Outlook 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 Visual C++. The source code of the project - both VB.NET and C# versions - can be downloaded here; the download is labeled Add-in Express for Office and .NET sample projects.

Step 1. Creating a COM add-in project

Make sure that you have administrative permissions before running Visual Studio. If you have Windows Vista, Windows 7, or Windows 2008, make sure that you run Visual Studio via Run as Administrator.

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

New Outlook COM add-in project

Choose Add-in Express COM Add-in and click OK.

This starts the COM Add-in project wizard.

The wizard allows choosing your programming language and specifying the oldest Office version your add-in needs to support.

Add-in Express project wizard - choosing your programming languag

Choosing a particular Office version will add corresponding interop assemblies to the project. Later on, in case you need to support an older or a newer Office version,you will be able to replace interop assemblies and reference them in your project. If you are in doubt, choose Microsoft Office 2000 as the minimum supported Office version. If you need background information, see Choosing interop assemblies.

Choose your programming language and the minimum Office version that you want to support and click Next.

The wizard allows creating add-in projects targeting several Office applications.

Add-in Express project wizard - choosing Office applications

You can choose one or more Microsoft Office applications in the above window. For every chosen application, the project wizard will do the following:

  • copy the corresponding interop assembly to the Interops folder of your project folder
  • add an assembly reference to the project
  • add a COM add-in module to the project
  • set up the SupportedApp property of the add-in module
  • add a property to the add-in module; the property name reflect the name of the chosen Office application; you will use that property to access the object model of the Office application loading your add-in, see Step 11. Accessing Outlook Objects.

Select which Office applications will be supported by your add-in and click Next.

Add-in Express project wizard - using strong names

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.

Choose Generate new or specify an existing .snk file and click Next.

The project wizard creates and opens a new solution in the IDE.

Creating a new COM add-in project

The solution contains an only project, the COM add-in project. The add-in project contains the AddinModule.vb (or AddinModule.cs) file discussed in the next step.

Step 2. Add-in module

AddinModule.vb (or AddinModule.cs) is the core part of the add-in project. It is a container for components essential for the functionality of your add-in. You specify add-in properties in the module's properties, add the components to 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.

  • 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 CurrentInstace 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

The module designer allows setting add-in properties and adding components to the module. 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 adds a corresponding Add-in Express component 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

The areas are shown in the screenshot below:

COM Add-in module

Note that the module itself provides a number of properties. You can click its designer surface and see the Properties window where you set the name and description of your add-in as well as the RegisterForAllUsers property, which is essential for distinguishing per-user and per-machine COM add-ins.

To add any Add-in Express component onto the module, you click an appropriate command in the Add-in Express Toolbox (#1 in the screenshot above). Let's see how to use it.

Step 4. Adding a new 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 adds an ADXOlExplorerCommandBar component to the add-in module.

Adding a new Explorer toolbar

You may use both Command Bar UI and Ribbon UI components on the add-in module. When your add-in 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 in the Ribbon UI.

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

Adding a CommandBar component to the add-in module

ADXOlExplorerCommandBar provides context-sensitive properties: they are FolderName, FolderNames, and ItemTypes. Add-in Express displays the 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.

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 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 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.

Step 5. Adding 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. Just click the appropriate button and see the result.

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 in Outlook 2007-2010, you use the Add ADXRibbonTab command that adds an ADXRibbonTab component to the module. The ribbons in which that tab will be shown are set by the Ribbons property. For an Outlook add-in, 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 2010 Explorer windows as well, set the Ribbons property to OutlookMailRead;OutlookMailCompose;OutlookExplorer.

Add Ribbon Tab command

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 ImageList, Image, and ImageTransparentColor properties to set the icon for the button.

Add Ribbon Tab command

See also Ribbon UI Components.

Step 7. Adding a new Inspector toolbar

To add a toolbar to Outlook 2000-2003 Inspector windows, use the Add ADXOlInspectorCommandBar command that adds an 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.

Note that the Ribbon UI replaces the main menu of Inspector windows in Outlook 2007 and all main menus in Outlook 2010.

For instance, to add a custom control to the popup shown by the File | New item in Outlook 2000-2007 Explorer windows, 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. You need the Office IDs from the screenshot to bind Add-in Express components to the corresponding controls:

Scanned Office IDs

  • 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 (see the screenshot above)

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!). 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 in the visual designer of the context menu component.

Context Menu component

Ribbon Context Menu component

The sample add-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 Office 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.

The Add ADXRibbonContextMenu. command in the Add-in Express Toolbox adds an ADXRibbonContextMenu component onto the add-in module. Then you set the Ribbons property that supplies context menu names for the ContextMenuNames property of the ADXRibbonContextMenu. 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. Adding an advanced Outlook region in Outlook 2000-2010

Creating a new Outlook region includes the following steps:

  • Use the Add-in Express Toolbox to add an Outlook Forms Manager, ADXOlFormsManager, onto the add-in module
  • Open the Add New Item dialog in Visual Studio to add an Add-in Express Outlook Form, ADXOlForm, to the project
  • 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 e-mail.

  • 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 OnADXBeforeCloseButtonClick 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 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 fires an exception for a top-level folder
            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 obtain the Selection object for a top-level folder, such as Personal Folders
  • There may be no items in the Selection object
  • 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,
        ' 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 adds (and removes) event components providing application-level events. In this sample, we add the Outlook Events component to 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 - Adding an advanced Outlook region in Outlook 2000-2010, 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 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 ProcessItemAdd procedure 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 ProcessItemAdd(ByVal Item As Object)
      MsgBox("The item with subject '" + Item.Subject + _
         "' has been added to the Inbox folder")
   End Sub

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

   Public Overrides Sub ProcessItemRemove()
      '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 item sorts in Outlook, see Event classes.

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 add-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 checkbox to the property page. The code below handles the CheckedChanged event of the checkbox 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 describes adding a property page to the Folder Properties dialog for a given 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 that dialog is located at the following UI path: 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 to add an ADXKeyboardShortcut to the add-in module.

Then, in the Properties window for the Keyboard Shortcut component, you choose or enter the desired shortcut in the ShortcutText property.

Keyboard Shortcut component properties

To use keyboard shortcuts, you need to set the HandleShortcuts property of AddinModule to true.

Now you handle the Action event of the component:


   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 the COM add-in

Choose Register Add-in Express Project in the Build menu, restart Outlook and find your option page(s), command bars, and controls, Ribbon controls, and custom task panes.

Registering Add-in Express Project

If you use an Express edition of Visual Studio, the Register Add-in Express Project item is located in the context menu of the add-in module's designer surface.

The add-in is run in the Outlook Explorer window

The add-in is run in the Outlook Inspector window

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

Step 17. Debugging the COM add-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 the COM add-in

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?

Here you can download the project described above, both VB.NET and C# versions; the download link is labeled Add-in Express for Office and .NET sample projects.

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

Also, in Add-in Express components we describe components that you use to customize the UI of the host application and handling its events.

Building Office COM add-in <<

>> Building Excel RTD servers

Back to Add-in Express for Office and .NET homepage