We recommend using Visual Studio 2017

How to: Prevent Outlook from Displaying a Form Region


There might be situations in which you do not want Microsoft Office Outlook to display a form region for a particular item. For example, if a contact item does not contain a business address, you can prevent a form region that shows the location of the business in a map from appearing.

Applies to: The information in this topic applies to VSTO add-in projects for Outlook. For more information, see Features Available by Office Application and Project Type.

To prevent Outlook from displaying a form region

  1. Open the code file for the form region you want to modify.

  2. Expand the Form Region Factory code region.

  3. Add code to the FormRegionInitializing event handler that sets the Cancel property of the FormRegionInitializingEventArgs class to true.

In this example, if the contact item does not contain an address, the Cancel property is set to true, and the form region does not appear.

            private void MapItFactory_FormRegionInitializing(object sender,
                Microsoft.Office.Tools.Outlook.FormRegionInitializingEventArgs e)
                Outlook.ContactItem myItem = (Outlook.ContactItem)e.OutlookItem;

                if (myItem != null)
                    if ((myItem.BusinessAddress != null &&
                            myItem.BusinessAddress.Trim().Length > 0) ||
                        (myItem.HomeAddress != null && 
                            myItem.HomeAddress.Trim().Length > 0) ||
                        (myItem.OtherAddress != null && 
                            myItem.OtherAddress.Trim().Length > 0))

                e.Cancel = true;

Creating Outlook Form Regions
Walkthrough: Designing an Outlook Form Region
How to: Add a Form Region to an Outlook Add-in Project
Walkthrough: Designing an Outlook Form Region
Walkthrough: Importing a Form Region That Is Designed in Outlook