You need to consider a variety of issues when designing your forms. Once you determine which form to modify and the purpose of your form, you have to open the form in design mode and decide the following:
In the rest of this chapter, you will learn how to perform all of these tasks.
Outlook provides an environment for creating and editing forms, which is sometimes referred to as the forms designer. The forms designer is automatically installed with Outlook.
NOTE
To obtain the Outlook Visual Basic help files, as well as the Microsoft Script Debugger, you need to install the Outlook Development Tools component after you install the Outlook client. You can install the Development Tools component by running Add/Remove Programs for Outlook 98. We will take a look at these components in the next chapter.
Opening a form in design mode is easy. If the form is not based on an Office document, you can use one of the following two methods: open a standard form of the type you want to modify and enter design mode; or select a form from a list of available forms, which automatically opens the form in design mode. To use the second method, follow these steps:
Figure 5-5 The Design Form dialog box in Outlook.
To create a new form based on an Office document and open it in design mode, do this:
For more information on customizing Office document forms, refer to the section "Extending Functionality with Office Document Forms" later in this chapter.
When designing your Outlook application, you need to decide whether you want to display, rename, or hide the default pages on the form. Your decision is based on what you will use the forms for. For example, if you wanted to preaddress an item sent to users to prevent them from modifying the values in the address field or knowing where the item was being sent, you could fill in the address information on the message and then hide the default pages. To change the display properties for a form page or to rename a default or custom page, enter design mode, click on the desired page, and then select the appropriate option from the Form menu. You can quickly see the display status of a form page in design mode since Outlook places parentheses around the name of any page that will be hidden at run time.
Outlook supports having separate layouts for compose and read form pages. The compose page appears when a user opens a form to compose a new item. The read page appears when a user double-clicks on an item to view it. The standard e-mail message is the best example of a form that effectively uses compose and read pages.
Outlook enables you to separate the compose page and the read page from a form so that you can add custom functionality to each of these user modes. Outlook supports compose and read pages on every customizable forms page. By default, the Message page on an Outlook Post form and a Message form have the Separate Read Layout option enabled. However your custom pages, by default, do not have this option enabled. To enable Separate Read Layout, in design mode, select the form page where you want separate compose and read layouts. On the Form menu, make sure there is a check mark next to Separate Read Layout. Outlook automatically copies the layout from the compose page to the read page. You can then select the layout you want to modify by displaying the Form menu and choosing either Edit Compose Page or Edit Read Page.
If you find that you are making extensive changes to the compose page, and you want to discard your read page and re-create it with the layout of the compose page, you can disable the Separate Read Layout option and then reenable it. Outlook will copy the layout of the compose page to the new read page.
The Field Chooser provides a simple way to drag and drop built-in and custom fields onto your form. When you drag and drop a field from the Field Chooser onto the form, Outlook creates the appropriate controls. If the AutoLayout option is enabled on the Layout menu, Outlook automatically positions your controls on the form. The controls that Outlook creates are based on the data type of the associated field. For example, if you drag and drop a field with a data type of text, Outlook will automatically create a text box control and typically a label control with the name of the field. If you drag and drop a field with a data type of Yes/No, Outlook will create a check box control with the Caption property set to the name of the field. Figure 5-6 shows a Post form with the controls for the Attachment, Categories, From, Icon, and Importance fields added using the Field Chooser.
Figure 5-6 You can drag fields from the Field Chooser to an Outlook form.
Shared FieldsOutlook supports shared fields in an item. Shared fields are any controls that are bound to the same field on both a compose page and a read page of a particular form. A user can modify the field on either page, and the changes will be available universally. Shared fields can also be used between Outlook forms—for example, when you respond to an item in a folder using a custom form, Outlook copies the values from the shared fields in the open item to the same field in the response item.
Outlook includes some important default fields, such as the address fields, that you should take advantage of when designing your application. In this section, we will briefly discuss the address fields, the Subject field, and the Message field.
The address fields include From, To, Cc, and Bcc. The address fields enable you to preaddress your form to individual users or distribution lists either by typing an address at design time or by setting the initial value of the fields. (You will see how to set initial values later in this chapter.) You can enable these fields if you want to allow the user to change the address, but most likely you will want to disable the To field and just expose the Cc field so that a user can send a copy of the form to another user. By default, the To field is exposed only on a Message form, but you can use the Field Chooser to drag and drop the To field or any other address field onto another type of Outlook form and set its initial value. This ensures that if the user attempts to forward the form, your address will automatically appear in the displayed Message form.
If you are preaddressing a form to a folder (as opposed to a user), either the folder has to be exposed in the Global Address List or you have to copy the folder address into your personal address book. To expose the folder in the Global Address List, you must have administrator rights on the Exchange Server system. To expose the folder in the Global Address List, launch the Microsoft Exchange Administrator program. Expand the folder trees to find and select the folder you want to expose. Choose File and then Properties. On the Advanced tab, uncheck the Hide From Address Book check box, and click OK.
The Subject field is important for two reasons. First, the text in the Subject field is the caption that appears at the top of a form. Second, the Subject field typically takes its value from the Conversation field, which we briefly looked at in Chapter 4. If you want to have a threaded view of the items in your application, the second point is important to remember.
The value of the Subject field can also be determined by formulas. For example, you can create a formula that sets the value of the Subject field by combining two other fields on your form.
The Message field is the only field for which text formatting, attachments, hyperlinks, and objects are supported. This extensive support allows you to embed instructions or other important material as an attachment, or to add shortcuts to web sites, files, or other Outlook items. To add an attachment to the Message field, open the item that you want to modify in run mode. From the Insert menu, select File and find the file you want to insert.
Note that if you are using HTML as your default mail format in Outlook, you can insert files only as attachments or text. If you are using the Outlook Rich Text mail format, you can insert files as attachments, shortcuts, text, or embedded objects. To add file shortcuts using the HTML mail format, you have to add hyperlinks in the Message field that points to your files.
Outlook supports many protocols that you can place in the Message field as hyperlinks. The most useful protocols with examples are listed here:
You can also express spaces in any of these protocols by using the characters %20. For example, to link to a specific message in your Inbox with the subject Earnings reports, you would use the following syntax for the Outlook protocol: Outlook:Inbox/~Earnings%20reports.
The Message control and its underlying field, the Message field, provide extensive functionality to your applications. However, there are some restrictions on usage of the Message control inside of an Outlook form. First, you should create only one Message control on an Outlook form. Since the Message control is automatically bound to the Message field, more than one control will cause a conflict regarding which content should be saved to the Message field. For example, if you have three Message controls on different pages in the Outlook form, and a user writes a different value to each control, Outlook will save the contents of only one of those controls. This means that only one value of the Message field will be displayed in all three Message controls.
NOTE
Outlook automatically displays a warning message if you attempt to put multiple Message controls on a form. If you need to sidestep this restriction because your application needs to span multiple pages with Message controls across each page, you should use a MultiPage control and keep only one Message control at the bottom of the form. For more information on how to use MultiPage controls, see the next section, titled "Using Controls."
Second, only the Message control accepts attachments or the hyperlinks we reviewed earlier in the chapter. The other controls in Outlook do not understand hyperlinks and will not automatically display and link information.
Third, the Message control is always bound to the Message field, and Outlook automatically establishes this binding. You cannot change it, nor can you set initial values of the Message control in design mode. You must either insert your hyperlinks, text, or attachments before designing the form or insert them programmatically.