Export (0) Print
Expand All

Developing Custom Forms Using Microsoft Outlook 2002 (Part 2 of 2)

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
 

Bill Jacob and Frank C. Rice
Microsoft Corporation

January 2003

Applies to:
   Microsoft® Outlook® 2002

Summary: Learn some of the core concepts related to developing custom forms using Microsoft Outlook 2002. This article consists of four lessons and is the second of two articles that cover some of the core concepts. The information in this article will help you understand what happens behind the scenes and provide techniques that can help you take advantage of custom forms in your Outlook solutions. (42 printed pages)

Contents

Lesson 3: Using Controls
  Fields Versus Controls
  Adding Controls to a Form
  Attributes of Controls
  Control Layout Features for Forms
  Distributing Controls on Outlook Custom Forms
Lesson 4: Working with Standard Outlook Controls
  Types of Controls
  Working with Controls
Lesson 5: Form Properties
  Additional Form Attributes
  Add Help to a Form
Lesson 6: Actions
  What is an Action?
  Action Settings
  Points to Remember

Lesson 3: Using Controls

Overview

This lesson describes how you can work with ActiveX® controls on a Microsoft Outlook® form. Without delving into the specifics of individual controls (which we will do in the next lesson), we will see how you can get the most out of the Control Toolbox and learn about the wide variety of layout features Outlook provides the form designer.

In order to get the most out of the following lessons, it is recommended that you review Lessons 1 and 2, if you have not already done so. Figure numbering in these lessons are a continuation from the previous lessons.

What You Will Learn

After completing this lesson, you will be able to:

  • Describe the different ways you can add controls to an Outlook form.
  • Understand the difference between a field and a control and what it means to bind a control to a field.
  • Use some of Outlook's form layout features to make it easier to design forms.

Recommended Reading

Fields Versus Controls

As we saw in Lesson 2, fields are the containers for storing every piece of information that Outlook keeps track of. When working with custom Outlook forms, you typically use the Control Toolbox to add controls to the form. These controls are not the actual fields, but are merely a front-end or user interface used to display the contents of a field.

Try this: Working with unbound controls

In this exercise, we will see what happens if do you not bind a control to a field. You will modify the Customer_Pet_Info contact form that you created in Lesson 2 so that you can keep track of your customer's pets.

  1. Open a new instance of our Customer_Pet_Info contact form and enter design mode.
  2. Switch to the Pet Info tab, display the Control Toolbox (Form menu) and drag a Textbox control to the Pet Info page on the form.
  3. Re-publish the form, and then launch a new instance of the form.
  4. On the Pet Info tab, enter a value into the text box and then save the contact.
  5. Reopen the contact and take a look at the Pet Info tab.

What do you see?

Answers: The text box is empty because controls do not store values.

Because controls cannot store any data by themselves, you must specify a field that the control should use to store the data. Once a field is bound (or linked) to the control, data will be preserved when an item is saved or sent.

Try this: Working with bound controls

In this exercise, we will see what happens if you bind a control to a field.

  1. Open a new instance of our Customer_Pet_Info contact form and enter design mode.
  2. Click the Pet Info page, right-click the textbox you added in the previous Try This, and choose Properties.
  3. Click the Value tab on the Properties dialog box.
  4. Click the Choose Field button, click All Contact fields, and then click Language.
  5. Click OK to close the Properties dialog box.
  6. Re-publish the form, and then close the current item without saving changes.
  7. Launch a new instance of the form.
  8. On the Pet Info tab, enter a value into the modified text box and then save the contact.
  9. Reopen the contact and take a look at the Pet Info tab.

    What do you see now?

    Answers: The value is displayed in the text box.

  10. Close the contact and then delete the contact from the folder.

In the vast majority of situations, controls need to be bound to a field. If you are not aware of the distinction between fields and controls—and the binding process which connects the two—you generally run into these issues:

  • You create a form with controls, and the data will not be preserved when the item is saved, posted or sent, as was illustrated in the previous steps.
  • You have problems working with fields or controls using Microsoft Visual Basic® Scripting Edition (VBScript) code because the syntax is different. (This will be covered in the section on VBScript.)

It is important to realize that whenever you use the Control Toolbox to add a control to a form, Outlook does not do anything to create or assign a corresponding field. You need to go into the Properties page of the control and assign the field as a separate step.

Adding Controls to a Form

In most cases, it is suggested that you use the Field Chooser dialog box to add fields onto a form instead of using the Control Toolbox, since Outlook will automatically bind the control to the field. However, with the exception of the Yes/No field type, Outlook will always create a text box and label, which might not be the type of control you wish to use for a particular field.

For example, if a particular field has only a set number of possible choices, or values, then you should use a ListBox or ComboBox control to represent the data in the field. This way, the user can only select one of a number of choices. In this case, you need to use the Control Toolbox to add the ListBox or ComboBox onto the form and then bind the field to the control yourself.

Adding Controls Using the Field Chooser

When a form is in design mode, you can use the Field Chooser dialog box to drag fields onto the form. When you do this, Outlook automatically creates default control(s) for the field and binds it to the field. From a usability point of view, this process can easily blur the distinction between fields and controls.

Different field types will result in different types of controls being created for the field. The following table lists the types of controls Outlook will automatically create when using the Field Chooser dialog box to add a field to a form:

Table 9. Control types

Field TypeControl(s) Created
TextLabel and text box
NumberLabel and text box
PercentLabel and text box
CurrencyLabel and text box
Yes/NoCheck box
Date/TimeLabel and text box
DurationLabel and text box
KeywordsLabel and text box
CombinationLabel and read-only text box
FormulaLabel and read-only text box

Adding Controls Using the Control Toolbox

You can use any of the following methods to add controls from the Control Toolbox to your form:

  • Click a control in the Control Toolbox and then click the form. The control appears in its default size. You can then drag the border of the control to change its size.
  • Drag a control from the Control Toolbox to the form. The control appears in its default size.
  • Double-click the control in the Control Toolbox, and then click in the form once for each control you want to create. For example, to create four command buttons, double-click the CommandButton control in the Control Toolbox, and then click four times in the form.

In most cases, you bind TextBox, CheckBox, ListBox, ComboBox, and OptionButton controls to fields. Other controls, such as Label and Image controls, that contain static information with which the user does not interact, are generally not bound to a field.

Note  As we will see later on in this article, you can also programmatically bind a field to a control using the ItemProperty property of the control.

One setting that isoften overlooked is Outlook's ability to bind a field to any property of a control. Most controls use the Value property to represent the data that is within the control. The Value property is typically the default property for a control, and Outlook will automatically bind the field to the default control property. However, you can override this and bind a field to any property of the control. This may be a useful feature in certain circumstances. To do this:

  1. In form design mode, right-click the control and choose Properties.
  2. Click the Value tab on the Properties dialog box.
  3. Change the property to use whichever control property you wish.

Attributes of Controls

Control States

Once a control is on a form in design mode, the control can be in any of the following three states:

Table 10. Control states

StateDescription
UnselectedAnother control or the form itself is selected.
SelectedYou are working with the control itself. Most controls are automatically selected when you put them on the form. In design mode, sizing handles appear around the control border when the control is selected. If you unselect the control, you can select it again by clicking the control.
ActiveYou are working with the contents of the control. Clicking a control that is selected puts the control in the active state. In this state, you can directly edit the control Caption or Value property, depending on the control. For example, if you click on a selected TextBox control, you will then be able to type text directly into the text box.

In both the Selected and Active states, you can use DEL, CTRL+X, and CTRL+C for the Delete, Cut, and Copy commands, respectively. In the Selected state, these commands are available on the shortcut menu and affect the control itself. In the Active state, these commands affect whatever text is selected inside the control; if no text is selected, these commands have no effect. These commands are not available on the shortcut menu for active controls.

Note that while we are on the topic of copying and pasting controls, Microsoft Outlook has a known problem when copying and pasting a relatively large amount of controls. This especially seems to happen when the controls are within other "container" controls, such as a MultiPage or Frame control. Often the controls will not appear to paste in the same order or appearance, but it is more important to realize that the bindings can often become lost or reversed. This problem happens in all versions of Microsoft Outlook and typically occurs when developers try to copy and paste all of the controls from the compose page of a form to the read page.

For more information, see the article OL2002: Controls Do Not Copy or Paste Correctly in Design Mode.

Control Properties

There are two types of properties for a control: Outlook properties and advanced properties. Outlook properties are the basic properties needed to design a control. Advanced properties offer additional functionality.

Outlook Properties

To set the Outlook properties for a control, right-click the control, and then click Properties.

The Display tab

Most of the properties affecting the control itself (as opposed to the field) are set on the Display tab of the Properties dialog box (see Figure 19).

Aa155728.odc_olcustfrm219(en-us,office.10).gif

Figure 19. Display tab of the Properties dialog box

Note that unlike the advanced properties, Outlook properties are set in the Properties dialog box, and must be set individually. You cannot select multiple controls on the form page and then use the Properties dialog box to change a value in all of the selected controls.

Most of the control settings that you typically use are exposed in the Properties dialog box. For example, on the Display tab you can set the control's name and most of the visual attributes of the control, such as the control's position on the form, the font and background color, and whether the control is visible, enabled, read-only, and can be resized.

While most of the settings on the Display tab are pretty straightforward, the one that typically causes the most confusion is the Resize with form setting. This setting will only affect a control's horizontal sizing. If the form is made narrower or wider, the control will shrink or stretch along with the form. However, if the form is made shorter or taller, the control will not resize. You can force a control to vertically resize but this must be done programmatically.

The Value tab

Everything on the Value tab is directly related to the bound field and is not directly related to the control (see Figure 20). The contents of this tab are dimmed until you select a field to bind the control to.

Aa155728.odc_olcustfrm220(en-us,office.10).gif

Figure 20. Value tab of the Properties dialog box

The Validation tab

Everything on the Validation tab is directly related to the bound field and is not directly related to the control (see Figure 21). The contents of this tab are dimmed until you select a field to bind the control to.

Aa155728.odc_olcustfrm221(en-us,office.10).gif

Figure 21. Validation tab of the Properties dialog box

Advanced Properties

To set the advanced properties for a control, right-click the control, and then click Advanced Properties. You can select multiple controls at once and then use the Advanced Properties dialog box to change values in all of the selected controls.

Using the Advanced Properties dialog box is probably very familiar to you if you have worked in Microsoft Visual Basic or Visual Basic for Applications (VBA) before. In Outlook, the Advanced Properties dialog box is the same as the Properties window in Visual Basic and VBA.

The properties available for each control vary, and exploring all of the different properties for the various controls is beyond the scope of this lesson. However, it is recommended that you understand the difference between the Properties dialog box and Advanced Properties dialog box as well as be familiar with the features of each.

Outlook Visual Basic Reference Help contains a number of topics that provide step-by-step information on how to use many of the control properties, including how to:

  • Change the name property of a control
  • Hide or show a control
  • Enable or disable a control on a page
  • Automatically calculate the result of a field
  • Make a control read-only
  • Allow multiple lines of text in a control
  • Align text in a control
  • Move a control one unit at a time
  • Align controls
  • Size controls
  • Space controls
  • Use z-order to layer controls

Control Appearance

The following summarizes some of the appearance features that Microsoft Outlook supports for controls on a form:

  • You can set the ForeColor property to determine the foreground color.
  • The BackColor property and BackStyle property apply to the control background.
  • The BorderColor property, BorderStyle property, and SpecialEffect property apply to the control border.

Outlook supports transparency, the display of whatever is behind an object instead of its background, in two areas: the background of certain controls and in bitmaps used on certain controls.

The Outlook Visual Basic Reference Help topic Ways to change the appearance of a control provides more information on these properties.

Using the Control Toolbox

The Control Toolbox identifies the controls you can add to a frame or page of a form. It is the same Control Toolbox that is used in the Visual Basic Editor and which is shared across all Microsoft Office applications.

Aa155728.odc_olcustfrm222(en-us,office.10).gif

Figure 22. The Control Toolbox

You can customize the Control Toolbox in many ways including:

  • Add pages to the Control Toolbox. Simply right-click any tab of the Control Toolbox and click Add Page.
  • Move controls from one page in the Control Toolbox to another. To do this, drag a control on any page to the label of another page, hold the mouse pointer over the label until the page appears on top, and then drag it onto the page.
  • Rename Control Toolbox pages.
  • Add other controls, including ActiveX controls, to the Control Toolbox.
  • Delete a control from the Control Toolbox. In the Control Toolbox, right-click the control you want to delete, and then click Delete <control name>.
  • Copy modified controls from the form to the Control Toolbox. For example, OK and Cancel buttons are commonly used command buttons. If you copy a pair of customized OK and Cancel buttons to the Control Toolbox, you can quickly add them to other forms.
Note  To reset any customizations to the Control Toolbox or to attempt to fix unexplainable behavior, rename the Outlook.box file. This file stores any custom settings or changes related to the Control Toolbox for a particular Office application. If Outlook does not find the Outlook.box when it starts, the application creates a new one. In a default installation of Office, Outlook.box can be found at C:\Documents and Settings\<username>\Application Data\Microsoft\Forms.

Control Layout Features for Forms

Following is a list of form layout features Outlook supports:

  • Selecting multiple controls at once so that you can set the same properties across more than one control at once.
  • Centering controls in a form.
  • Right-align a control on a form.
  • Changing the grid size for easy positioning of controls.
  • Option to show or hide the grid.
  • Have controls automatically resize when the user changes the size of the form.
  • Set tab order of controls on a page.

For more information, see the following section in the Outlook Visual Basic Reference Help: Work with Forms, Work with Fields and Controls, and Align, Arrange, and Size Controls.

Grouping Controls

A group is two or more controls on a form that you can work with as a single unit when designing a form. It is not relevant to actually using a form. You can include any control on the form in a group. Once controls belong to a group, you can work with the entire group, or you can select a single control.

There are many ways to work with groups and the controls in groups. After you select a group, you can do any of the following:

  • Size all controls in the group at the same time.
  • Separate controls in the group so each is independent of the others.
  • Show the group shortcut menu for quick access to commands that affect the group.
  • Select a single control within the group without separating controls in the group. You can then change property settings of the selected control without affecting any other control in the group.

For more information on working with groups on Outlook forms, see the Outlook Visual Basic Reference Help section Groups in Microsoft Forms.

Working with Pictures

You can use the Image control to have Outlook display a graphic on a form. After adding the Image control to the form, go to the Advanced Properties dialog box and set the Picture property to a graphic stored on the file system.

You can also set a picture as the background for a form page. To do this, right-click an empty area of the form page, click Advanced Properties, and then select a picture from the file system.

For more information on working with pictures on a form, see the Outlook Visual Basic Reference Help section Work with Pictures.

Custom ActiveX Controls

In this section, we will take a look at the various standard controls that Outlook includes which are specifically designed for use on Outlook forms. However, as with most other forms in other development environments, developers can add any ActiveX control to an Outlook form.

A thorough discussion of working with custom and third-party ActiveX controls on Outlook forms is beyond the scope of this lesson. These components are commonly created using Visual Basic, but you can also create them in any programming language that supports the Component Object Model (COM).

While Outlook uses the same forms technologies as VBA UserForms, it is important to note that there are inherent limitations with using custom controls on an Outlook form. For instance, Outlook only supports the Click event for controls, so you cannot directly use other events that a control might support. As an example, when using the MultiPage control, it is often crucial to be able to trap the event that occurs when a user clicks on a specific page of the control. You can do this on a VBA UserForm, but you cannot use this event on an Outlook form. This means the control's functionality may be severely impaired and defeat the purpose of using the custom control in the first place.

Using some creative techniques, you may be able to work around these limitations in several ways:

  • Use a Visual Basic ActiveX component instead. The Visual Basic component can display a Visual Basic form and give you all of the power of Visual Basic forms. The server can automate Outlook to transfer data back and forth between the Outlook form or item and the ActiveX component.
  • Place the custom ActiveX control on the Outlook form and then bind an Outlook field to a non-default property of the control. Usually this approach is problematic since the value in the field will not update until the user clicks on another control or presses the TAB key.

You can find addition information on these and other topics related to customizing Outlook forms with VBScript, Visual Basic, and VBA in the excerpt from Building Applications with Microsoft Outlook Version 2002 by Randy Byrne.

Distributing Controls on Outlook Custom Forms

Control licensing tends to be a complex issue since there are multiple issues and bugs involved.

Distribution Methods

Outlook 2002 does a better job of supporting ActiveX controls than its predecessors. Still, the distribution of ActiveX controls used on custom forms remains one of the most perplexing problems encountered by Outlook developers. Unlike Visual Basic, Outlook does not provide a setup.exe program to install and register components of your application.

Lesson 4: Working with Standard Outlook Controls

Overview

Outlook uses the same basic controls that other Office applications use; however, many form designers are surprised to learn that the controls often are implemented differently on Outlook forms. In this lesson, we will take a look at each of the standard controls and discuss how they can—and should—be used on a custom Outlook form.

What You Will Learn

After completing this lesson, you will be able to:

  • Understand how each control should be used from a user interface point of view.
  • Set up each control so that it will work as expected on an Outlook form.
  • Explain how each control behaves with regard to whether or not it is bound to a field.
  • Recognize which controls may have limitations when used on an Outlook form.

Recommended Reading

Types of Controls

Label Controls

Label controls (Figure 23) are simple to use mainly because they serve a single purpose: they typically "label" other controls or display text on the form. In our previous exercises, we have already seen label controls when we have added fields onto the form. Outlook automatically created them when a field was added to the form from the Field Chooser dialog box.

Aa155728.odc_olcustfrm223(en-us,office.10).gif

Figure 23. Label control for the Initial Visit text box

Labels are usually created:

  • Automatically when a field is dragged from the Field Chooser dialog box onto a form. A Label and a Textbox control are usually placed on the form side-by-side, with the Label containing the name of the field.
  • By using the Control Toolbox. The default text in the Label control is Label1 and can be changed by double-clicking the control and editing the text in the control, or right-clicking the control and then clicking Properties.

Because a Label control does not allow a user to change text when using the form, they typically are not bound to a field. However, you can bind a label to a field if you want a user to be able to see the content of the field and not change it. However, using a TextBox control and setting it to read-only serves the same purpose.

Note  While you can change the text of a label by using the Outlook user interface, if you programmatically change the value, it will not be preserved. It will revert back to its previous value after exiting design mode, saving the form, or sending the form. This occurs because of the way Outlook forms are designed. You should typically change the value of an underlying bound field and not a control, but since labels are typically not bound, this does not usually apply in this case.

TextBox Controls

A TextBox control is probably the most common control used to allow data entry on a form. TextBox controls are typically bound to either a standard or user-defined field so that the information entered into the TextBox control is saved with the item. Labels are commonly used in conjunction with a TextBox control to help identify what type of information should be entered into the TextBox. A good example would be the Job Title text box on the General page of a standard Outlook contact form. Figure 23 illustrates a label text box combination.

Text boxes are usually created:

  • Automatically when a field is dragged from the Field Chooser dialog box onto a form. In this scenario, the TextBox control is automatically bound to the field and a label is also created that the developer can use to uniquely identify the TextBox control.
  • By using the Control Toolbox. This will place a TextBox control on the form, but the control will not be bound to a field. You typically should right-click the control, click Properties, and specify a field on the Value tab. If a TextBox control is not bound to a field, any data entered into the control will be lost when the form is saved or sent.

You can set the Multi-line property (MultiLine property in the Advanced Properties window) of a textbox to True so that it will display multiple lines. TextBox controls can display large amounts of data, but there are field size limitations that generally prevent you from entering more the 32K of data per form.

For more information, see the article OL2002: Text That You Insert into Field Is Missing.

CommandButton Controls

A CommandButton control performs a certain action when the button is clicked. In the case of custom Outlook forms, this typically means that a VBScript subroutine is executed. But there are also built-in Outlook dialog boxes that are available from the Field Chooser dialog box. You can bind these dialog boxes to a CommandButton control so that the user can click the button and display the built-in Outlook dialog box.

Aa155728.odc_olcustfrm224(en-us,office.10).gif

Figure 24. Full Name command button on an Outlook contact form

CommandButton controls are usually created:

  • By using the Control Toolbox. Since the control will typically be referenced in VBScript, you should rename the control and place the proper text on the control. For example, if you are using a CommandButton control to allow the user to print the form, the caption of the control might be Print and the name of the control might be cmdPrint. The caption is the text that appears on the CommandButton control itself when it is on the form.

    To have Outlook execute VBScript code when the user clicks the button, you create a Click event for the control. In this case, the event procedure would be:

    Sub cmdPrint_Click()
      ' code to be executed goes here
    End Sub
    
    
  • By dragging a recipient field (To, From, CC, BCC) from the Field Chooser dialog box. Outlook creates a CommandButton control and recipient control, and both are bound to the recipient field. If you click the CommandButton control, Outlook displays the Select Names window so that you can pick a name from an address book. Because the recipient control is also bound to the same field, picking a name from the address book changes the name in the recipient control.
  • By dragging an Outlook dialog field from the Field Chooser dialog box. These fields have ellipses (...) after them to indicate that they will display a window. On a contact form, for example, you can drag the Categories... or Check Name... command onto the form to create a CommandButton control. When the CommandButton control is clicked, it will display the Categories or Check Names dialog box. You do not need to create any VBScript to make this work. If you access the Outlook properties of the control, you will see that the Type property is listed as Button.

CheckBox Control

A CheckBox control is typically used to represent Boolean (Yes/No, True/False, On/Off) data types and is typically bound to a Yes/No field.

Aa155728.odc_olcustfrm225(en-us,office.10).gif

Figure 25. A checkbox on the Customer_Pet_Info form

CheckBox controls are not designed to be mutually exclusive, meaning that each CheckBox control can be either selected or cleared and one CheckBox control does not affect the settings of other CheckBox controls. In general, OptionButton controls should be used for mutually-exclusive functionality. This distinction is part of the standard Microsoft Windows® user interface guidelines. If for some reason you need to make CheckBox control values mutually exclusive, you can write VBScript code to manually set all other fields to False when a particular CheckBox control is selected.

CheckBox controls are usually created:

  • By dragging a standard or user-defined Yes/No field from the Field Chooser dialog box. An example would be the Journal field on a contact form.
  • By using the Control Toolbox. Typically the control should then be bound to a Yes/No field, however, you can also bind a CheckBox control to a Number field. In this case, Yes is equal to -1 and No is equal to 0 (zero). Note that if you bind the control to a Text field, the CheckBox control will not work.

OptionButton Controls

OptionButton controls provide a way for a user to select one of several options on a form. You can see an example of option buttons if you click the File menu and then click Archive. The two option buttons are at the top of the Archive dialog box.

Aa155728.odc_olcustfrm226(en-us,office.10).gif

Figure 26. Archive form with two option buttons

There are multiple steps required to make option buttons fully functional on an Outlook form. The key points to remember are:

  • All of the option buttons in a set must be bound to the same field. Outlook does this for you automatically when you bind the first option button. If you do not bind the option button to a field, then when you send or save the form, the option buttons will be blank.
  • The field should typically be a Text field, as the example below illustrates. However, you can use other field types that can store multiple values, such as a Number field. Be sure to set the value of each control to an appropriate value for that particular type of data, such as 0, 1, or 2 for a Number field. Most importantly, do not use a Yes/No, or Boolean field. These values should be used for check boxes.
  • The value of each control should be set to whatever the value will be in the Text field. The Caption property of the control typically should match the value.
  • If you are using more than one set of option buttons on a form page, you must either put the option buttons in a Frame control, or any other control that would be considered a "container" control.

For more information, see the article OL2002: How to Use Option Buttons on an Outlook Form.

Try this: Create option buttons on a form

In this exercise, we will add some option buttons to the Customer_Pet_Info form that we have been working on. We now want to keep track of whether or not the pet is male or female. To do so, we will add a label with two option buttons below it so that the user can click either male or female. Note that in this scenario, only one option can be selected at a time, so option buttons are the appropriate choice (as opposed to check boxes).

  1. Create a new instance of the Customer_Pet_Info form and enter design mode.
  2. Click the Pet Info tab of the form.
  3. On the Form menu, click Control Toolbox.
  4. Drag two OptionButton controls from the Control Toolbox to the form page.
  5. Right-click the first option button and then click Properties.
  6. On the Value tab of the Properties window, click New. Type Sex as the name of the field and then click OK. Note that the field is a Text field. Still on the Value tab, the Property to use setting should be set to Value. Change the setting for the Value box (below the Property to use drop down list) to Male.
  7. Click the Display tab and change the Caption to Male. This text will actually appear on the form. Click OK.
  8. Right-click the second option button and on the shortcut menu, click Properties.
  9. On the Value tab of the Properties window, notice that the control is automatically bound to the same field that was created for the first option button. Change the Value box setting to Female.
  10. Click the Display tab, change the Caption to Female, and then click OK.
  11. Using the Control Toolbox, add a Label control above the two OptionButton controls. Right-click the label and click Properties. Change the Caption to Sex: and change the Name property to lblSex. Click OK.
  12. Re-publish the form. Close and do not save changes to the form.
  13. Open a new instance of the form.
  14. Set the name of the contact to Fickle Fred. Click the Pet Info page of the form, set the Pet Type to Frog, and set the Sex to Female.
  15. Click Save and Close.
  16. Re-open the Fickle Fred contact item and click the Pet Info tab of the form. Note that Female is currently selected, indicating that the user's selection is being preserved when the item is saved (see Figure 27).

    Aa155728.odc_olcustfrm227(en-us,office.10).gif

    Figure 27. Pet Info tab on the Customer_Pet_Info form

  17. Click the All Fields tab of the form and set the drop down list to show User-defined fields in folder.

    What is the value of the Sex field?

    Answer: Female (see Figure 28).

    Aa155728.odc_olcustfrm228(en-us,office.10).gif

    Figure 28. All Fields tab on the Customer_Pet_Info form

ListBox and ComboBox Controls

The ListBox and ComboBox controls provide the same type of functionality but are slightly different. The ListBox control displays a list of information directly visible on the form, while the ComboBox control only displays a list when the dropdown button is clicked.

Aa155728.odc_olcustfrm229(en-us,office.10).gif

Figure 29. Sales Range ComboBox control and Best Region ListBox control

In addition to providing a single column of data, ListBox controls can be configured so that they display more than one column. However, accomplishing this requires code to populate the control. To set the column widths of a multicolumn ListBox or ComboBox control, you can specify the width, in points, for all the columns in the ColumnWidths property. Specifying 0 (zero) width for a specific column hides that column of information. If you want to hide all but one column of a ListBox or ComboBox control from the user, you can identify the column of information to appear by using the TextColumn property. Similarly, you can control which column of values is used for the control when the user makes a selection by specifying the column number in the BoundColumn property.

While ListBox and ComboBox controls are typically bound to a Text field, you can also use the Keywords field to store the data for a ListBox control, but not a ComboBox control. The Keywords field is designed to store multiple values, so when a ListBox control is bound to a Keywords field, Outlook automatically adds checkboxes in front of the possible values within the ListBox control. The user can then click one or more values in the ListBox control and all of the values will be stored in the Keywords field. However, Keywords fields can only store 255 characters, so this type of field should be used only if the user will be selecting from a relatively few possible values.

For more information, see the article OL2002: ListBox Bound to Keywords Field Unexpectedly Changes.

Working with Controls

Populating ListBoxes and ComboBoxes at Design time

There are a variety of ways to populate a ListBox or ComboBox control on an Outlook form. The controls can be populated either at design time or at run time.

If you have a predetermined and unchanging set of possible values, you can populate the ListBox control or ComboBox control when designing the form.

Try this: Populating a ListBox at design time

The following steps illustrate how you can add a ListBox control onto the Customer_Pet_Info form to keep track of a pet's size.

  1. Open a new instance of the Customer_Pet_Info form and enter design mode.
  2. Click the Pet Info tab.
  3. On the Form menu, click Control Toolbox. On the Control Toolbox, drag a ListBox control onto the form.
  4. Right-click the ListBox control and then click Properties. On the Value tab, click New. Type Pet Size for the Name and click OK. In the Possible Values box, type Extra Small;Small;Medium;Large;Extra Large and then click OK.
  5. Add a label control to the top of the ListBox control and change the Caption to Size:.
  6. Re-publish the form. Close and do not save changes to the form.
  7. Launch a new instance of the form and click the Pet Info tab of the form.

You can select any item in the ListBox control, and the selected value will be stored in the Pet Size user-defined field (click the All Fields tab to verify).

Populating ListBoxes and ComboBoxes at Run Time

Many solutions require that the possible values in a ListBox or ComboBox control be up-to-date or refreshed regularly. The values are typically stored in some other location and need to be retrieved every time the item is opened. To accomplish this, you can add VBScript code to the form and use an Item_Open event to run code whenever an item is opened. This code will fill the ListBox or ComboBox control with possible values.

There are several ways in which you can use VBScript to populate a ListBox control or ComboBox control.

PossibleValues Property

If you have a relatively simple ListBox or ComboBox control to work with, you can automate the design time steps by using the PossibleValues property of the control. This property is unique to Outlook and should be set to a semicolon-delimited String, similar to the design time steps earlier.

Try this: Use the PossibleValues property

To see how the PossibleValues property can be implemented, follow these steps:

  1. On the Outlook Tools menu, point to Forms, and then click Design a Form.
  2. In the Standard Forms Library, click Message, and then click Open.
  3. Click the (P.2) tab.
  4. On the Form menu, click Display This Page.
  5. On the Form menu, click Control Toolbox. On the Control Toolbox, drag a ListBox control onto the form.
  6. Right-click the ListBox control and then click Properties. On the Value tab, click New. Type ListBoxField for the name and click OK. Leave the Possible Values field blank, and then click OK.
  7. On the Form menu, click View Code. Type or paste the following VBScript code and then close the Script Editor:
    Sub Item_Open()
       ' Sets FormPage equal to the page (P.2)
       Set FormPage = Item.GetInspector.ModifiedFormPages("P.2")
       ' Sets Control to a ListBox called ListBox1.
       Set Control = FormPage.Controls("ListBox1")
       ' Assign values to the ListBox.
       Control.PossibleValues = "Blue;Green;Red;Yellow"
    End Sub
    
    
  8. Click the All Fields tab, and then on the Form menu, click Display This Page.
  9. On the Form menu, click Run This Form.
  10. Click the P.2 page of the form.
  11. Click any item in the ListBox control.
  12. Click the All Forms page and make sure the Select from drop down list displays User-defined fields in this item.

    The ListBoxField user-defined field is listed and the value you selected on the P.2 page is also listed there.

  13. Close both forms and do not save the changes in either case.

AddItem Method

The AddItem method is typically used when you are looping through a series of data. As you loop through the data, you add items to the ListBox or ComboBox control, one item at a time.

For an example on using the AddItem method, see the article OL2002: How to Populate a Combo Box with Your Contacts.

List Property

ListBox and ComboBox controls have a List property that allows you to specify an array which contains the data the control should use. If your solution is already using arrays to store data, using this approach can provide the simplest programming solution. In addition, one key advantage to using the List property is that if you wish to populate the ListBox or ComboBox control with multi-column data, the List property supports multi-dimensional arrays to accomplish this.

Try this: Use the List property to populate a ListBox

Use the following steps to populate a two-column ListBox control with data from your Contacts folder.

  1. On the Tools menu, point to Forms, and then click Design a Form.
  2. In the Standard Forms Library, click Message, and then click Open.
  3. Click the (P.2) tab.
  4. On the Form menu, click Control Toolbox. On the Control Toolbox, drag a ListBox control onto the form. Make sure the ListBox control is sized large enough to fill most of the form page.
  5. On the Form menu, click View Code. Type or paste the following VBScript code and then close the Script Editor.
    Sub Item_Open()
       Dim FullArray()
       ' Sets the name of page on the form (P.2)
       Set Page = Item.GetInspector.ModifiedFormPages("P.2")
       ' Sets Control to a ListBox called ListBox1.
       Set Control = Page.Controls("ListBox1")
       ' Set the Session object
       Set olns = Application.Session
       ' Get the default Contacts folder
       Set ConFolder = olns.GetDefaultFolder(10)
       ' Get the items in the folder
       Set ConItems = ConFolder.Items
       ' Get the total items in the Contacts folder
       NumItems = ConItems.Count
       ' Resize array to handle total no. of folder items
       ReDim FullArray(NumItems-1,2)
       ' Loop through the items in the Contacts folder,
       ' filling the array with data and keeping track
       ' of the number of contacts found.
       NumContacts = 0
       For I = 1 to NumItems
          Set itm = ConItems(I)
          If Left(itm.MessageClass, 11) = "IPM.Contact" Then
             NumContacts = NumContacts + 1
             FullArray(NumContacts-1,1) = itm.FullName
             FullArray(NumContacts-1,2) = itm.CompanyName
          End If
       Next
      
       ' Set the control to handle 2 data columns
       Control.ColumnCount = 3
      
       If NumItems = NumContacts Then
          ' They are all contacts, so use the FullArray
          Control.List() = FullArray
       Else
          ' There is some DistLists, so use the smaller
          ' ConArray to eliminate blank values in the ListBox
          Dim ConArray()
          ReDim ConArray(NumContacts-1,2)
          For I = 0 to NumContacts–1
             ConArray(I,1) = FullArray(I,1)
             ConArray(I,2) = FullArray(I,2)
          Next
          Control.List() = ConArray
       End If
    End Sub
    
    
  6. On the Form menu, click Run This Form.
  7. Click the P.2 page of the form.

    The ListBox control will be populated with the data from your default Contacts folder (see Figure 30).

    Aa155728.odc_olcustfrm230(en-us,office.10).gif

    Figure 30. ListBox control with listing from Contacts folder

Note   ListBox and ComboBox controls that are bound to a field do not support the Click event. You must use the PropertyChange event or CustomPropertyChange event instead to detect a change of value in the control.
Note   When the ListStyle property is set to Option, the MultiSelect property determines whether check boxes or option buttons appear in the list. When MultiSelect is set to Single, option buttons appear in the list. When MultiSelect is set to Multi or Extended, check boxes appear in the list.

Match Entries in a List to Entries Typed by Users

You can use the MatchEntry property to determine how a ListBox or ComboBox control responds to input from the keyboard. For example, as you type an entry into a list box, the setting of the MatchEntry property determines how Outlook attempts to match that input to existing entries in the list.

  1. Open a form in design mode.
  2. Drag the ListBox or ComboBox control from the Control Toolbox to the form.
  3. Right-click the control, and then click Advanced Properties.
  4. Click the MatchEntry property and enter a value in the Apply box.

To set the MatchEntry property to provide no matching, select None. To compare the most recently typed letter to the first letter of each entry in the list (the first match in the list is selected), select FirstLetter. And to compare the user's entry and an exact match in an entry from the list, select Complete.

Two things to note about using matched entries:

  • The matching feature resets after 2 seconds (6 seconds in the Asian-language version). For example, if you have a list of the 50 United States and you type "CO" quickly, you will find "Colorado." But if you type "CO" in longer than 2 seconds, you will find "Ohio" because the auto-complete search resets between letters.
  • If you select Complete matching, it is a good idea to sort the list entries alphabetically (you can use the TextColumn property to do this). If the list is not sorted alphabetically, matching may not work correctly. For example, if the list includes Alabama, Louisiana, and Alaska, respectively, then "Alabama" is considered a complete match if the user types "ala." In fact, this result is not complete because there are two entries in the list that could match what the user entered. Sorting alphabetically eliminates this.

MultiPage and TabStrip Controls

The MultiPage and TabStrip controls visually provide similar functionality but are quite different architecturally. In addition, both are somewhat limited because Outlook only supports the Click event for controls.

When would you use the MultiPage control as opposed to the TabStrip controls? If you use a single layout for data, use a TabStrip control, and then map each set of data to its own tab. If you need several layouts for data, use a MultiPage control, and then assign each layout to its own page. Unlike the page of a MultiPage control, the client region (the area that accepts controls) of a TabStrip control is not a separate form but a portion of the form that contains the TabStrip control. The border of a TabStrip control defines a region of the form that you can associate with the tabs. When you place a control in the client region of a TabStrip control, you are adding a control to the form that contains the TabStrip control.

The main advantage of the MultiPage control is that it allows you to add more controls to a form than would typically fit on a form page. In fact, the standard Outlook forms use a Multipage control to organize fields and display relatively large amounts of information, such as on the contact form.

Aa155728.odc_olcustfrm231(en-us,office.10).gif

Figure 31. The MultiPage control

Aa155728.odc_olcustfrm232(en-us,office.10).gif

Figure 32. The TabStrip control

Be aware that when using the Click event for either control in VBScript, the event fires when you click in the main portion of the control's page. The syntax for the event procedure is Sub <pagename>_Click(). Note, however, that the Click event does not fire when you click on the tabs at the top of the MultiPage control. That would be when most developers would expect the event to run as you could then programmatically perform some operation when the user clicks on another tab in the MultiPage control. For more information on the MultiPage control and the TabStrip control, see the Microsoft Outlook Visual Basic Reference Help.

Outlook's Recipient Control

Aa155728.odc_olcustfrm233(en-us,office.10).gif

Figure 33. Recipient controls

The recipient control is the only standard control on a form designed to store resolvable e-mail addresses, Web pages, phone numbers, and so forth. This control is built into the Outlook.exe and is not a separate ActiveX control, or OCX. However, Outlook registers this control like other controls and it can be added to the Control Toolbox as well as be directly added to a form. In the list of controls, it is referred to as the Outlook Recipient Collection Edit OLE Control. However, to use it, you should drag one of the recipient-based fields onto the form instead of directly using the recipient control. You cannot create a user-defined field of this type, so this control is only designed to be used with the standard recipient fields.

Outlook's Message Control

Aa155728.odc_olcustfrm234(en-us,office.10).gif

Figure 34. Message control

The Message control is the only standard control on a form in which you can insert files, items, or objects. This control is built into the Outlook.exe and is not a separate ActiveX control, or OCX. However, Outlook registers this control like other controls and it can be added to the Control Toolbox as well as be directly added to a form. In the list of controls it is referred to as the Outlook DocSite OLE Control. However, to use it, you should drag the Message or Notes field onto a form instead of directly using the DocSite control. You should not have more than one of these controls per form; otherwise, Outlook will display a warning, both during design-time and run-time. If you do add more than one control on a form, the additional control(s) may not update correctly and can cause usability issues.

Following are some rules to keep in mind when using the Message field:

  • Each form can contain only one Message control per page. For example, you can have a Message control on the Compose page of a form and a Message control on the Read page of the same form.
  • You cannot have a Message control on the Message page and a duplicate control on page 2 or on a page following the Compose or Read page.
  • If the form does not have the Separate Read Layout option selected on the Form menu for the page that contains the Message control, the form can only contain one Message control.
  • The Message control is automatically bound to the Message field.

Lesson 5: Form Properties

Overview

This section will cover those aspects of form design that are by their very nature, form-level properties. These attributes of a form are typically set in design mode on the Properties page. On the Properties page, the information such as Description, Category, and Form Number help users find and identify your form in the New Form dialog box. If you do not want users to modify your form, you can protect a form by assigning a password to it.

What You Will Learn

After completing this lesson, you will be able to:

  • Find the various form-level properties.
  • Understand what each of the properties is used for.

Recommended Reading

Additional Form Attributes

You can set various properties of a form by using the Properties tab while in form design mode. People new to working with Outlook forms often overlook this tab. It is important to be familiar with the form's options so that you can use them effectively when designing a form solution.

Click here for larger image

Figure 35. The Properties page of a form (click picture for larger image)

Send Form Definition with Item

One very important attribute of your form is whether to save the form definition with the form. The form definition includes all the fields and the code you add to the form. If you do not plan to publish your form to a forms library, then you must select the Save form definition with item check box on the Properties page of the form. The form definition includes all the new data you add to the form when you send the form to another user. If you plan to publish your form to a forms library that other users have access to, such as an Organization Forms Library or a public folder library, you do not need the form definition since it is stored in the library.

The form definition can add considerable size to your form. For this reason, it is usually best to publish the form into a common forms library and have Outlook use the form from the forms library. If you embed the form definition into every item that uses the form, this can possibly cause performance problems since the form definition will be sent or posted with every item. In Outlook 98 and later versions, this option is off by default.

Click here for larger image

Figure 36. Save Form Definition with Item message (click picture for larger image)

Icons

Form icons provide a quick visual means of determining the type of item they represent. For example, if you wanted to design a form that was not like any of the default Outlook forms, you might want to specify a custom icon to make your items stand out from the regular Outlook items.

It is important to note that as soon as you customize a form, the icons for the form revert back to the standard Post icons. Unless you are designing a custom post form, you should always go to the Properties page of a form and reset the icons back to the default icon for that particular type of item.

Click here for larger image

Figure 37. The Post icons on a contact form (click picture for larger image)

Icons are installed through Setup by choosing the Visuals for form design option in the list of installation options. By default, these icons are installed in C:\Program Files\Microsoft Office\Office\Forms.

To change the icons associated with a form, click the Change Large Icon or Change Small Icon button on the Properties page of the form. Then select the .ICO file that isappropriate for the type of form being used. The small icon is used throughout all of Outlook with the exception of the Manage Forms dialog box, which uses the large icon.

Note  To create your own icon, you can use a tool such as Image Editor, which is available from the Visual Basic 6.0 CD (Disk 1) or the Microsoft Visual Studio® 6.0 CD (Disk 3) at the following location:\Common\Tools\VB\Imagedit\Imagedit.exe.

If you are viewing items in a table view and the icon does not seem to be the proper icon, there is a good chance the item was one-offed. See Lesson 1 for more information on one-offed items.

It is also important to understand that Outlook does not store icons within an item. Icons are always stored in a published form, so they are inherently linked. This is the primary reason you may have noticed that icons in a view tend to take a while to update. Also, this means that if an item does not have access to its published form, the icons will revert back to the standard icons. As with most things that are linked—such as embedded files—there are advantages and disadvantages to this architectural design. One of the key advantages of the design is that item sizes are kept minimal.

Use Word Mail

You can specify that Microsoft Word runs in the Message control on a form. This allows users to take advantage of spell checking, the thesaurus, and the formatting that Word offers when creating their mail. To set Word 2002 as the editor for all default mail formats (Plain Text, Rich Text, and HTML), with the form in Design mode, click the (Properties) page, and then select the Always use Microsoft Word as the e-mail editor check box.

If you are using Outlook 2000 and your default mail format is Rich Text Format, then selecting this option will allow you to specify that Word runs in the Message control on you form. You cannot use WordMail with a mail message whose default mail format is Plain Text or HTML.

To choose Word as the e-mail editor for all of your mail messages (click Tools, and then click Mail Format from the Options menu), When using a mail message or post, you might be able to tell that WordMail is being used because Outlook will display a message stating that it is starting WordMail as the editor. However, you can also tell you are using WordMail by noticing Word's telltale end-of-document character, the large underscore, in the message or notes field.

Click here for larger image

Figure 38. Setting to select Word as editor (click picture for larger image)

Protecting a Form's Design

On the Properties page of a form, you can select the Protect form design checkbox so that Outlook will prompt for a password when someone tries to switch the form into design mode.

For more information regarding Microsoft's policy on invalid passwords, see the article 189126: Microsoft's Policy Regarding Missing or Invalid Passwords.

Note that setting a form password is only a deterrent so that typical end users cannot modify the form. You can actually retrieve the form's password using the Outlook object model, and even if a form is password-protected, you can still use the ScriptText property in the object model to retrieve the VBScript code within the form. For more information, see the article 288554 OL2002: Outlook Custom Form Passwords Are Not Secure.

Make a Published Form Hidden or Visible

You can make a published form hidden so that users cannot see it in a form library or under the Actions menu if it is published to a folder. To do this, select the Use form only for responses checkbox in the Properties page of the form while in design mode.

Or, you can set the same form property by following these steps:

  1. On the Tools menu, click Options, and then click the Other tab.
  2. Click Advanced Options, click the Custom Forms button, and then click the Manage Forms button.
  3. If the forms library you want to use is not displayed, click the Set button to pick a different forms library or folder.
  4. Click the form you want to change, click the Properties button, and then select or clear the Hidden check box.

    Aa155728.odc_olcustfrm239(en-us,office.10).gif

    Figure 39. The Hidden checkbox on the Form Properties window

When you make a form hidden, you basically are creating a "second-level" form that can only be launched from a "first-level" form. For example, let's say you have a contact form that is used to record company information. Much like you can reply to a mail message, you can create an action that launches another contact form to record specific information about an employee of the company. This situation implies that there is additional VBScript or logic in the forms so that the solution maintains a relationship between the company item (the "parent" item) and the employee items (the "child" items). However, the basic premise is that you do not want the user to be able to launch an employee form by itself; you only want them to be able to launch an employee form from the contact form. By hiding the employee form when it is published in the folder, users will not be able to launch it by itself off of the Actions menu.

The Use form only for responses setting is a bit of a misnomer since it implies it is solely for message forms. However, this setting simply hides any form when it is published in a folder or forms library.

Show or Hide Fields When Printing and Saving a Form

If you add additional standard fields to a custom form, you typically need to take the extra step to select the Include this field for Printing and Save As setting so that the additional standard field will print. This setting is selected automatically when user-defined fields are added to a form; however, Outlook does not select this setting when standard fields are added. To access this setting, follow these steps:

  1. With the form in design mode, right-click the field you want, and then click Properties.
  2. Click the Validation page.
  3. Select or clear the Include this field for Printing and Save As check box.

    Aa155728.odc_olcustfrm240(en-us,office.10).gif

    Figure 40. The Include this field for Printing and Save As setting

Add Help to a Form

When creating a custom form with Outlook, there is no direct way to add a Help file. There are a number of workarounds for this with the more common approaches summarized in this section.

Create a "Help" Page on the Form

To add a page of help text to your form, follow these steps:

  1. Click the page you want to add text to.
  2. On the Form menu, click Rename Page.
  3. In the Page Name box, type Help, and then click OK.
  4. Drag a TextBox control from the Control Toolbox (click Control Toolbox on the Form menu) to the form.
  5. Right-click the TextBox control and click Properties.
  6. On the Display page, select the Multi-line check box, and then click OK.
  7. Type your help text in the text box.
  8. Right-click the text box control and then click Properties.
  9. On the Display page, click Read Only, and then set any other display attributes as needed.
  10. On the Form menu, click Run This Form to see what the help page will look.
  11. If you are satisfied with the changes, click the Tools menu, point to Forms, and then click Publish Form.
    Note  Because a Help file cannot be associated with a form, you cannot use the HelpContextId property to create Help for an Outlook form. If the Compose page is different from the Read page, you may need to create separate Help pages.

Aa155728.odc_olcustfrm241(en-us,office.10).gif

Figure 41. An example of a Help page

Lesson 6: Actions

Overview

Actions are a powerful tool available to form designers. They provide a lot of functionality that typically can prevent a forms developer from writing code in certain circumstances. Understanding how actions work can greatly improve your ability to create workflow and routing solutions.

What You Will Learn

After completing this lesson, you will be able to:

  • Summarize what an action is and what it can be used for.
  • Understand the various options you have when defining an action.
  • See how actions can cause some confusion in areas such as transferring fields and retaining attachments.

Recommended Reading

What is an Action?

Actions are a very powerful feature of Outlook forms that allow you to create a wide variety of forms solutions without writing programming code. They are primarily used with mail message forms and can be designed to create elaborate routing models. However, you can use actions with all types of Outlook forms.

Custom actions are a way to create a new item from an existing item, with the option to include data from the original item. For example, Voting buttons are an application of this technique where the Voting button framework already exists in Outlook. You can then take this framework, add your own data, and create a custom action.

Caution  The term action is commonly used to denote many things in relation to Outlook and you should always be sure that it is always being used in the right context. The Rules Wizard supports custom actions, which are add-ins that must be written in C++. The term custom action can also be used to denote a custom form action that you create for a form. There is an Actions menu in Outlook, which can be used to launch custom form actions, but which can also be used in the general sense of the term action, where it simply starts a process such as New Letter to Contact. When using the term action, it is important to make sure that you and the customer are talking about the same thing.

One use of an action is to launch one Outlook form from another form. You are probably already familiar with Outlook's default Reply, ReplyAll, and Forward actions. These actions are implemented on the read page of a standard Outlook mail message so that when you receive a message and open it, you can then perform an action on the form.

Click here for larger image

Figure 42. The standard Reply, Reply to All, and Forward actions (click picture for larger image)

Actions also provide a way to store different types of items in a single folder. Typically Outlook does a good job of helping to ensure that each folder only contains items that match the type of folder. It does this mainly through a feature called AutoCreate, where if you drag and drop one type of item into a folder of a different type, Outlook converts the item into the type that matches the folder. In addition, the default form for a folder must match the folder type. However, you can have an action launch a form of a different type, and when the user saves the item, the item will directly save into the folder even though the type does not match.

Action Settings

Each action you create can have a variety of settings or properties that tell the action how to behave. To access these settings, use the Actions page of a form while you are in form design mode.

Click here for larger image

Figure 43. The Actions page of a message form with default actions (click picture for larger image)

To create a new action, click the New button at the bottom of the Actions page of a form. This will display the Form Action Properties window so that you can set all of the properties you want your action to have.

Aa155728.odc_olcustfrm244(en-us,office.10).gif

Figure 44. The Form Action Properties window

When an action is executed, you have the following options you can use to customize the action:

Action Name

You give the action a name, which is the text that appears on the menu and toolbar button.

Form to Launch

The This action creates a form of the following type setting specifies the form that the action will launch. The form can exist in any forms library or folder, but for mail messages, the custom forms are typically located in the Organizational Forms Library or one of the default Outlook forms.

Format of the Message or Notes field

You can specify how the Message or Notes field is formatted by choosing an option in the When responding drop down list:

  1. Do not include original message  The body of the new form is empty.
  2. Attach original message  The original message is included in the new message as an attachment.
  3. Include original message text  The body of the message is copied into the new form with some blank lines added to the top to delimit the messages.
  4. Include and indent original message text  Same as above, except the message text is indented.
  5. Prefix each line of the original message  The indented text is prefixed with the default character that the user specified. The prefix is specified in the Subject prefix box. For example, for forwarded messages, the prefix is FW.
  6. Attach link to the original message  The original message is not attached to the new one, but only linked. This is typically used for items in a public folder, where the item is always accessible to everyone, therefore the link will always be valid. If the link is invalid, possibly because the message is sent to someone without access to the public, a generic error message is displayed when the recipient tries to click on the link.
  7. Respect user's default  Use whatever setting the user has specified as the default. For example, you might use this setting if you created a new form based on the default Outlook reply form. Then, any reply messages using the new form would retain the RE: in the subject line.

Addressing the New Form

You can specify how the new form will be addressed:

  1. Reply  Copies the From field to the To field.
  2. Reply to All  Adds the From field to the addressees on the To field and copies the original CC field to the new CC field.
  3. Forward  Leaves the To and CC fields blank. In addition, this is the only option that preserves attachments in the original message and also preserves other features, such as VBScript.
  4. Reply to Folder  Typically used with Post forms; it pre-addresses the form so that it will be saved in the folder and also clears the Subject field.
  5. Response  Used with voting buttons.

Menu and Toolbar Options

You can specify whether the action is available on the menu or toolbar button:

  • Neither  You would typically choose this option if you have VBScript code in the form that programmatically executes the action. This would prevent users from initiating the action themselves.
  • Menu only  The action is only available on the Outlook menu, not the toolbar.
  • Menu and Toolbar  The most common choice. The toolbar buttons are added to a new toolbar called Response.

Prefixing the Subject Field

You can specify whether or not the Subject field is prefixed with a custom string of text, such as Approved:

How the Form is Opened

You can specify how the new form is opened:

  • Open the form  Just like Outlook's default actions, the new form is displayed on the screen.
  • Send the form immediately  Outlook does not display the form; it is sent right away. This is commonly used for Approved or Declined actions.
  • Prompt the user to open or send  This works exactly like when you respond to a meeting request and Outlook prompts you if you want to send the reply immediately or whether you want to add some comments.

    Aa155728.odc_olcustfrm245(en-us,office.10).gif

    Figure 45. The response dialog box

You can use the default reply forms built into Outlook (these are the forms listed on the Actions page), or you can disable any of these forms and create a custom reply form. You can disable any or all of these forms on the Actions page by clicking the line describing the form, clicking Properties, and then clearing the Enable check box. The custom reply forms that you create are listed on the Actions page in design mode in the form.

You can create custom buttons and menu commands, specify what happens when the user chooses the custom button or menu command you add, or create a button or menu command that opens a task, a Calendar item, or even a note. You can specify that the form use standard Reply and Forward headers, and you can even add prefix text, such as RE: to the Subject field of your custom reply form.

You can send information without opening a reply form by pre-addressing a custom reply form to go to a specific e-mail address or to a public folder.

Support Notes

  • You need to use the Forward action to have attachments included in a Reply. So even if your action is a Reply, use the Forward action to preserve attachments.
  • If the original form contains VBScript and launches a new form that is not exactly the same as the original, the VBScript code is copied into the new form, thus creating a one-off item. When the recipient opens the item, they will be prompted to enabled/disable macros. You can learn more about one-off items in Lesson 1: Working with Items and Forms.
  • Not all standard fields are copied over to the new form that is launched. There is no documentation as to which fields are copied over, and considering the different combinations of items, this would be difficult to create. However, all user-defined fields are copied over to the new form.

Try This: Creating a Custom Action

In this exercise, we will add a custom action to the Customer_Pet_Info form so that it is easy to send the contact information to someone else.

  1. Create a new instance of the Customer_Pet_Info form and enter design mode.
  2. Click the Actions page of the form.
  3. Click the New button at the bottom of the Actions page.
  4. For Action name, enter Forward Contact.
  5. For the Form name, select Forms and then select Message from the Standard Forms Library, and then click Open.
  6. Set When responding to Attach original message.
  7. Set Address form like a to Forward.
  8. Set the Subject prefix to FW: and leave the other settings at their defaults.
  9. Click OK.
  10. Re-publish the form. Close and do not save changes to the form.
  11. Launch a new instance of the form, enter a Full Name, and save the contact.
  12. Re-open the contact and notice that there is now a new toolbar for the action.
  13. Click the Forward Contact button.

    What happened?

    Answer: A new mail message was launched with the original contact attached as an embedded object (see Figure 46).

    Aa155728.odc_olcustfrm246(en-us,office.10).gif

    Figure 46. Mail message with original contact embedded

Points to Remember

  • If you have an item that is based on a published custom form, if you do anything to change the form definition or field schema, Outlook will automatically create a one-off form. Typical symptoms include the "Enable/Disable" macro warning, the icon reverting back to the default icon, and the size of the items increasing unexpectedly.
  • There are three locations (folders, items, and published forms) where user-defined fields can be stored. While developing an Outlook forms solution, it is important to always be aware of exactly where the fields are located and how you might be affecting any existing items. You should always try to maintain consistency of fields when creating a solution.
  • If you do not bind a control to a field, any data in the control will be lost when the item is saved, sent, or posted. Controls are simply the user interface for a field. Fields are where data is actually stored.
  • Outlook provides a wide variety of form layout features and you should be familiar with both the Outlook Properties window and the Advanced Properties window.
  • There are a variety of form options available on the Properties page of a form while it is in design mode. Do not overlook these.
  • Actions are a powerful way to create workflow-type form solutions without writing any programming code.
Show:
© 2014 Microsoft