UI Manager Sample for .NET 4.0

This sample demonstrates how to customize the user interface (UI) of Microsoft Office Outlook 2007 by implementing extensibility interfaces in an add-in. This sample uses extensibility interfaces to create a Ribbon customization, a custom task pane, and a custom form region.

4 Star
6,224 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

using System;
using System.Runtime.InteropServices;
using Outlook = Microsoft.Office.Interop.Outlook;
using Microsoft.Vbe.Interop.Forms;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;

// Need to add reference to Microsoft.Vbe.Interop.Forms.
// COM tab: Microsoft Forms 2.0 Object Library (the first one if there are more than one).
namespace UiManagerOutlookAddIn

    public class FormRegionConnector : Outlook.FormRegionStartup

        #region Fields

        private const String _formRegionName = "SimpleFormRegion";


        #region FormRegionStartup implementation

        // This method is not CLSCompliant because of its Office parameters.
        public object GetFormRegionStorage(
            string FormRegionName, object Item, int LCID,
            Outlook.OlFormRegionMode FormRegionMode, 
            Outlook.OlFormRegionSize FormRegionSize)
            switch (FormRegionName)
                case _formRegionName:
                    return Properties.Resources.SimpleFormRegionOfs;
                    return null;

        // This method is not CLSCompliant because of its Office parameter.
        public object GetFormRegionIcon(
            string FormRegionName, int LCID, Outlook.OlFormRegionIcon Icon)
            return PictureConverter.ImageToPictureDisp(

        public object GetFormRegionManifest(string FormRegionName, int LCID)
            return Properties.Resources.SimpleFormRegionXml;

        // This method is not CLSCompliant because of its Office parameter.
        public void BeforeFormRegionShow(Outlook.FormRegion FormRegion)
            if (FormRegion != null)
                // Create a new wrapper for the form region controls, 
                // and add it to our collection.
                    FormRegion.Inspector, new FormRegionControls(FormRegion));