Create custom Outlook GUI: ribbon tabs,
toolbar buttons, context menu in Delphi
Add-in Express™
Develop Outlook plug-ins in DelphiAdd-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:
You may find useful a free sample Outlook add-in in Delphi with source code. Example of creating an Outlook add-inBelow 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 projectIn 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. 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. 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 moduleThe 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 also presents you with add-in properties, events and useful methods:
3. Add a custom Ribbon tab to OutlookIn 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: 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 OutlookAdd-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: Then use a special component, Forms Manager, which allows specifying what pane to use, where to show it and when. 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 pagesUsing 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. 6. Create a custom Outlook UI: toolbar, main menu, context menusToolbars, 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:
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. Technical information:
Customizing Outlook main menuCommandBar 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: Customizing Outlook context menusYou 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. More about Outlook-specific menu components. 7. Intercepting user actions and Outlook eventsYou 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: To intercept clicking button Reply in the pre-ribbon, Outlook CommandBar UI, you use the Built-in control Connector component: 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. 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. 8. Customizing the Outlook Navigation PaneOutlook 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: 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-inBefore 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: 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:
|