Create custom Outlook GUI: ribbon tabs,
toolbar buttons, context menu in Delphi

Add-in Express™
for Microsoft® Office and Delphi® VCL

Develop Outlook plug-ins in Delphi

Add-in Express for Office and Delphi VCL allows you to write a COM add-in for all Outlook versions with minimal time and coding.

It provides several Outlook-specific features that let you create a slick Outlook user interface with little effort. You can use Ribbon designers for creating custom ribbon tabs, BackstageView etc.; design-time Outlook form and view regions, version-neutral handling of Outlook events, Outlook Solution module, Navigation Pane shortcuts, option pages and property pages, special components for creating the CommandBar UI in pre-Ribbon Outlook: context-sensitive toolbars, main menu and context menu and more.

Key features of Add-in Express for Outlook plugins:

  • Visual designers and project-specific components of Add-in Express for customizing the Office Ribbon UI as well as the old-style Outlook GUI, which makes equally easy to create new or customize existing ribbons, ribbon tabs, task panes for Outlook 2007 - 2021 as well as build toolbars, menus and sub-menus for Outlook 2003 - 2000.
  • Special components for customizing Outlook windows, Navigation and Reading panes, Outlook bar with Advanced Regions in Outlook 2021 - 2000.
  • Special command bar components for adding context-sensitive toolbars to the Outlook Explorer and Inspector windows in pre-Ribbon Outlook versions.
  • A component to create custom items for Outlook main menu and context menus.
  • A component to add a custom navigation module to the Outlook 2010 - 2021 Navigation Pane. In earlier Outlook versions you can add shortcuts and shortcut groups to the Navigation pane; shortcut points to an Outlook folder, file-system location or a URL.
  • Outlook-specific components to create option and property pages, intercept events and shortcuts of any Outlook built-in controls and embedding your code into built-in event handlers.
  • Add-in Express directly integrates its projects with the Office Automation Server components and allows you to access Outlook objects and handle their events.

You may find useful a free sample Outlook add-in in Delphi with source code.

Example of creating an Outlook add-in

Below you can see a step-by-step instruction on how to write a version-independent COM add-in for Microsoft Outlook in Delphi: add a custom ribbon tab, build a command bar and custom task pane, extend Outlook main menu and context menus. In the Add-in Express Developer Guide, you can find one more example of Writing Outlook add-in.

1. Create a new Outlook COM add-in project

In the Delphi IDE, close all opened projects, select the "File|New|Other..." item on the main menu, and run the "Outlook Add-in" wizard on the "Add-in Express VCL" item category of the "New Items" dialog box.

Creating an Outlook  COM add-in project with the Add-in Express wizard

On the wizard pages, you specify if your add-in will be installed with administrative or user privileges, define option and property pages and also specify if setup projects targeting WiX and InnoSetup.

The wizard generates a new project, adds the defined property pages as active forms, and opens the project in the Delphi IDE.

A new Outlook add-in project

MyOutlookAddin1_IMPL.pas on the screenshot above is the Add-in module - a special component for programming Outlook add-ins with Add-in Express, which is the heart of your Outlook add-in project.

2. Customize Outlook Add-in module

The add-in module is a placeholder for add-in components such as ribbon tabs, toolbars, context menus, keyboard shortcuts, etc. You will find an appropriate component in the Add-in Express tab on the Tool Palette and add the component to the module.

The add-in module

The add-in module also presents you with add-in properties, events and useful methods:

Add-in name, description, and load behavior
TOutlookApplication representing the Outlook application loading your add-in
When the add-in completes start-up routines or is required to shut down
Before the Ribbon XML markup is created, before and after the Ribbon XML is loaded
Find Outlook CommandBar or Ribbon controls
Activate Ribbon tab (Outlook 2010 - 2021)

3. Add a custom Ribbon tab to Outlook

In the Tool Palette, select the Add-in Express tab, find the Ribbon Tab component, and add it to the add-in module. Specify the controls to be located on the tab using the visual designer of the Ribbon tab component:

Ribbon tab visual designer

At add-in startup, the add-in module scans all Ribbon-related components, lets them generate their part of the XML markup, and supplies the resulting Ribbon XML to Office Outlook.

4. Create custom task panes for Outlook

Add-in Express supports two pane types which differ in the GUI, available positions and functionality. One of them is called a Custom Task Pane, and it works in Outlook 2021 - Outlook 2007. You define such panes in the project wizard windows. Add-in Express documentation also shows how to add a task pane to an existing Add-in Express project.

In addition to standard custom task panes, Add-in Express provides Advanced Form and View Regions for Outlook 2021 - 2000. To create an advanced region, you need to add a special descendant of TForm to your project:

Adding an advanced Oulook form

Then use a special component, Forms Manager, which allows specifying what pane to use, where to show it and when.

Configuring the form settings

The above screenshot demonstrates configuring a custom form (TMyOutlookForm) to be shown in Explorer windows, the layout is called "elRightSubPane". The context is specified as "every Outlook folder the default item type of which is MailItem". A new instance of the form will be created whenever you navigate to a folder; you can also choose to have just one instance of the form per folder or across all folders.

Layouts available for your forms are listed on this page: Advanced Outlook view and forms regions in Delphi.

You can find a number of sample projects demonstrating solutions for typical tasks in the HOWTO section: Advanced Outlook Regions - Delphi samples.

5. Add custom options and property pages

Using the Add-in Express project wizard you define property pages to be added to the Options dialog box (on the Tools menu in pre-Ribbon Outlook versions) or to the Properties dialog box for a given folder (or all folders). The wizard creates the property and options pages (TActiveForm descendants) and adds a sample TEdit control as well as a code sample that demonstrates controls' events processing.

Custom Outlook Inbox property page

6. Create a custom Outlook UI: toolbar, main menu, context menus

Toolbars, main menus and context menus are examples of CommandBar - the term of the pre-ribbon era. To support pre-ribbon Outlook versions, you use CommnadBar-style components:

  • Toolbars: Outlook Explorer and Outlook Inspector
  • Main Menus: Outlook Explorer and Outlook Inspector
  • Context Menu

The components take into account Outlook multi-Explorer and multi-Inspector windowing system. They also provide context-sensitivity: you can specify folders that toolbar will be shown for. You can narrow down the folder list by specifying the default item type.

You can also connect an Outlook command bar component to a built-in command bar: just specify the name of a built-in or an existing toolbar in the CommandBarName property. The commandbar components provide a property for preventing the toolbar from showing in the Outlook Ribbon UI (it is available for Outlook 2007 Inspector, Outlook 2010 - 2021 Inspector and Explorer).

The screenshot below shows adding a button onto a custom Explorer toolbar; the toolbar will be shown in Outlook 2007 - 2000.

A custom CommandBar button in the Add-in Express visual designer

Technical information:

Commandbar name, position, supported Office applications, visibility and protection
Temporary or permanent
Collection of command bar controls
Whether the toolbar will display in the Outlook Ribbon interface (UI)

Customizing Outlook main menu

CommandBar based main menus exist in Outlook 2003 - 2000 and in the Explorer window of Outlook 2007. The Outlook-specific main menu components allow adding custom items to the main menus in the Explorer and Inspector windows in a way similar to the toolbar designer:

Adding custom items to the Oultook Explorer main menu using visual designer

Customizing Outlook context menus

You use the Context Menu component (TadxContextMenu) to add custom items to context menus in Outlook 2002 – 2007, Outlook 2000 context menus are not customizable. To fully comply with the Ribbon-based context menu system of Outlook 2010 - 2021, you also use the Ribbon-style Context Menu component, TadxRibbonContextMenu.

Adding custom items to Outlook context menus

More about Outlook-specific menu components.

7. Intercepting user actions and Outlook events

You can intercept the action using two components that allow connecting to built-in commands of the Outlook UI.

You can intercept pressing the built-in Reply button in the Outlook Ribbon UI using the Ribbon Command component as follows:

Intercept pressing the built-in Reply button in the Outlook Ribbon UI

To intercept clicking button Reply in the pre-ribbon, Outlook CommandBar UI, you use the Built-in control Connector component:

Intercept pressing the built-in Reply button in the Outlook CommandBar UI

You can intercept other commands as well by setting appropriate values to the IdMso and BuiltInId properties. You can find IDs of all Office commandbar controls using our Built-in Control Scanner. The IDs of Office built-in ribbon controls are available on MSDN.

Also, you can use a Keyboard Shortcut component to intercept pressing Outlook keyboard shortcuts and key combinations.

Intercept pressing Outlook keyboard shortcuts

You use the TadxOutlookAppEvents component, which connects to Outlook events in a version-neutral way taking into account the multi-explorer and multi-inspector Outlook environment.

Connecting to Outlook events

8. Customizing the Outlook Navigation Pane

Outlook 2010 - 2021 provide a feature called Solution Module. It allows adding a custom navigation module to the Navigation Pane; the module defines a folder hierarchy.

With Add-in Express you add a Solution Module component onto the add-in module and specify the folder hierarchy, including built-in and custom folder icons:

Solution Module

With Outlook 2007 - 2000, you use the Outlook Bar Shortcut Manager component. It allows creating groups of shortcuts in the Navigation Pane, every shortcut pointing to an Outlook folder, a file-system path or a URL.

And you can add an advanced region below the Navigation Pane, see Step 5 above.

9. Running and deploying the Outlook add-in

Before registering the add-in on the development machine, make sure that Outlook.exe is not running in the Processes list of the Task Manager window. To register the add-in, choose the menu Run | Register ActiveX Server in the Delphi IDE. Then run Outlook, and see your panes shown. Open the custom navigation module, find your Outlook Ribbon tab or toolbar and click on the button. Your custom Outlook 2010 UI may look similar to this:

Custom Outlook 2010 UI: ribbon tab with a button

On the customers' machines, you'll need to register the ActiveX DLL that your add-in project creates. Pay attention that the project wizard allows specifying these options:

  • create an InnoSetup setup project or not;
  • create a WiX setup project or not;
  • whether registering the add-in requires administrative permissions or user permissions.