Create custom Outlook form in VB.NET, C#, C++.
Customizing Outlook 2007 - 2000 forms.

Add-in Express
for Microsoft .net


Add-in Express Home > Add-in Express.NET > Online Guide > Customizing Outlook forms

Customizing Outlook forms

Creating Outlook 2007 add-in in .NET - Flash videoOutlook customization has a long-dated history. To customize an Outlook form you can use the built-in tools for form designing and publishing (see the Tools | Forms | Design a Form menu in Outlook). You can use HTML and VBScript / JScript to customize folder views, and Outlook Today is an example of this approach.

Advanced Outlook Form Regions

For Add-in Express, Outlook is a featured application. In this view, Add-in Express provides Outlook developers with Advanced Outlook Form Regions for customizing Outlook bar, To-Do bar and Navigation pane as well as special features for Outlook plug-in development. Now you can embed custom .NET forms into the Outlook Explorer and Outlook Inspector windows and replace folder views with custom .NET forms in Outlook Today style. Also, you can replace the Outlook Today page with your custom form.

The form-embedding technology of Add-in Express consists of three key parts: 

  • ADXOlForm (or the form) – this is the base class for all forms embeddable into Outlook windows 
  • ADXOlFormsManager (Outlook Forms Manager) – this component provides the Items collection and a number of events 
  • Item – every item of the ADXOlFormsManager.Items collection specifies context and visualization properties for a form

You add a form to your project by choosing a corresponding item in the Add New Item dialog. Then, using the context menu, you add an Outlook Forms Manager to the add-in module. Finally, you add an item to the Items collection of the manager, bind the item to the form, and specify items properties such as ExplorerLayout and InspectorLayout that specify the placement of the form in explorer and inspector windows. Additionally, you can specify Outlook folders and / or item types, the form will be shown for.

The sample below is written in VB.NET, but you can develop your forms in Visual C#, C++ and RO Chrome.

Creating a custom Outlook form

To create a custom Outlook form, please follow the first three steps described in sample Outlook add-in project first.

1. Add the Outlook Forms Manager

Use the corresponding command in the context menu of the add-in module in order to add the Outlook Forms Manager to the module.

2. Add a custom form embeddable into Outlook

To add a custom form to your Outlook add-in project, choose the corresponding wizard in the Add New Item Dialog.

3. Customize the form

On your form, you can use any .NET controls such as calendars, edit boxes, grids, list views, etc. In this example, we added a label to show when the selected message was sent.

Custom form

4. Access Outlook objects

ADXOlForm provides access to all Outlook objects and events. For example, you can handle the ADXSelectionChange event to synchronize your form with selection changes in the current Explorer window:


 Private Sub ADXOlForm1_ADXSelectionChange() _
      Handles MyBase.ADXSelectionChange
      Dim OlApp As Outlook._Application = CType(OutlookAppObj, _
         Outlook._Application)
      Dim Explorer As Outlook._Explorer = OlApp.ActiveExplorer()
      Dim Selection As Outlook.Selection = Explorer.Selection
      Dim Item As Outlook.MailItem

      If Selection.Count <> 0 Then
         Item = CType(Selection.Item(1), Outlook.MailItem)
         SentLabel.Text = "Sent: " + Item.SentOn
         Marshal.ReleaseComObject(Item)
      End If
      Marshal.ReleaseComObject(Selection)
      Marshal.ReleaseComObject(Explorer)
   End Sub

You can also handle the ADXBeforeFormShow event to initialize your form for the current inspector window:


   Private Sub ADXOlForm1_ADXBeforeFormShow() Handles Me.ADXBeforeFormShow
      'If the form is shown in Explorer then exit.
      If Me.InspectorObj Is Nothing Then Exit Sub
      Dim Inspector As Outlook.Inspector = CType(InspectorObj, _
         Outlook.Inspector)
      Dim Item As Outlook.MailItem = CType(Inspector.CurrentItem, _
         Outlook.MailItem)
      SentLabel.Text = Item.Subject
      Marshal.ReleaseComObject(Item)
   End Sub

5. Specify context for your form

Add a new item to the Items collection of the Outlook Forms Manager, select your form class in the FormClassName property, and specify Outlook context as follows: 

Binding form to Outlook context

  • If the form is to be shown in the Explorer window, use the ExplorerItemTypes, ExplorerLayout, ExplorerMessageClass(es), and FolderName(s) properties.
  • If the form is to be shown in the Inspector window, use InspectorItemTypes and InspectorMessageClass(es), and FolderName(s) properties.

Note! When several context-sensitivity related properties are set simultaneously, the Add-in Express Extensions for Outlook handles them using the OR Boolean operator.

6. Run the add-in

Finally, you rebuild the add-in project, run Outlook, and find your custom form embedded.

Custom form in action

Writing Outlook COM add-ins <<

>> Building Excel RTD servers

Back to Add-in Express.NET homepage




Client login

 

Login 

Password 

 

Remember me

Forgot my password