Are you a world traveler? ZoneTick is a cool utility that'll help you stay in touch over multiple time zones!
 
Using Outlook to Create Forms  
Nik Okuntseff  MS Exchange Server Programming 

Using Outlook to Create Forms

Raw MAPI forms programming is difficult. In addition, it is time consuming. Major difficulty is to implement a form server itself. Installing it, as I have shown in previous topics, may be done rather painlessly. There exists another task if you are going to use a separate application (viewer) to launch your forms. You need to implement a few form related interfaces such as IMAPIMessageSite, so that form servers could successfully communicate to it. It is possible, however, to piggyback on Outlook via its automation interfaces as I have shown in previous section. It does not perform very well, though, but programming efforts are a lot easier.
 

Exchange Forms Designer - a Predecessor

Outlook predecessor was the Exchange client application. It was not as rich as Outlook, but there was something coming with it that simplified creation of forms. It was called Exchange Forms Designer. It is a client application, as well as Exchange client itself. To install it you need the Exchange client disk, navigate to its Eng/Efdsetup subdirectory and run the Setup.exe from there. Exchange Forms Designer is using 16 bit Visual Basic to perform its tasks. I am mentioning it here for historical reasons to eliminate possible confusion about what tool should you use to design forms. As Exchange is the predecessor of Outlook, so is Exchange Forms Designer the predecessor of Outlook built-in capability to design forms. Exchange Forms Designer keeps its form definitions in files with .efp extensions. Capabilities of Exchange Forms Designer are poorer than that of Outlook. For example, you can't add a button on a form and associate code with it (it is possible, however, when using 16 bit Visual Basic 4.0 directly on form files). You should consider using Outlook instead.
 

About Outlook Forms

Perhaps the most dramatic advantage of Outlook in regards to forms is its capability to create, install and run forms. You can design a form in a kind of a Visual Studio graphical environment by putting controls on a form, associating properties and code (VBScript) with them. Outlook provides powerful functionality, which allows for creation of usable MAPI forms in a matter of days instead of months. This comes with its price, though. Performance is one aspect here. Also, Outlook forms are only a subset of all possible forms. For example, you would not be able to create something like the Checkers form. Visual interface elements are limited to edit boxes, buttons, and some other common elements. Code should be written in VBScript. Everything is event driven. For example, it is easy to associate code with an event such as opening or closing the form, but impossible to create something like a timer which is automatically invoked every interval. In spite of all these limitations the opportunity is powerful and in many cases this would be just enough.

Outlook comes with its own file format for forms. A form description can be saved in a file with .oft extension (abbreviated from Outlook form template). You can take a look at contents of such files. Usually they are located in the Templates subdirectory of Microsoft Office installation. Also, implementation details of Outlook form servers are different from raw MAPI form servers. For example, one of message attachments for a raw MAPI form is a form server executable file (you can examine the Checkers form attachment to see this). In case of Outlook forms the number of attachments is 4 instead of 3. Also, an attachment that appears to represent a form server has a .tmp extension.

A lot of things that you normally see in Outlook are forms. When you compose a new message you fill out the Message form. When you create a new contact you do it by invoking the Contact form. Some of the forms such as the Message form are one page dialogs. Others such as the Contact form have multiple pages.

Outlook comes with a few predesigned forms. They are: Message, Post in a folder, Appointment, Meeting Request, Contact, Task, Task Request, Journal Entry and Note. You may explore their possibilities by navigating to File - New menu list. Conceptually, each form is designed for a well defined purpose. The Message form creates an outgoing message, the Note creates a memo note and so on.

You can modify an existing form or design your own by removing all controls from an existing one and starting all over from scratch. You can add controls such as buttons to a form and even associate Visual Basic scripts with them. Everything including writing scripts is done within Outlook environment. Some standard easy tasks such as rearranging controls, introducing custom properties, associating them with controls, etc. may be accomplished even without any programming at all, by just using the possibilities of the rich Outlook client program.
 

Installing Outlook Forms Help

You may find it useful to install the Outlook Forms Help Add-In to your Outlook client. This is a rich collection of documents describing how one may use Outlook forms. Once installed, you would see the "Microsoft Outlook Forms Help" item on the "Help" menu, which navigates you to the help files.

To install, download the Olfrmhlp.exe file from http://support.microsoft.com/support/kb/articles/q161/0/82.asp.
This is a self extracting file, which results in the Readme.txt and Formshlp.exe files. The Formshlp.exe installs the Outlook Forms Help, the Readme.txt contains instructions.

Alternative ways of getting the Olfrmhlp.exe file are listed in the following MSDN article:
"OL97: Microsoft Outlook Forms Help Available on MSL".
 

Creating Simple Outlook Forms:

Suppose we need to create two simple custom forms. I'll call them the Status Update Request and the Status Update. They are supposed to work together. A manager who wants a status update from an employee sends a Status Update Request to the employee. The employee hits the Reply button. This action invokes the Status Update form, which the employee may fill out and send to the manager.

To create the Status Update Request form do the following:

  • Invoke a new mail Message form by selecting File - New - Mail Message menu item.
  • Start modifying it by switching to the design mode by selecting its Tools - Forms - Design This Form menu.
  • While editing Compose Page resize the Message control. Introduce the default value for the Subject edit box by right clicking on it and selecting Properties. Select Value tab and check the "Set the initial value of this field to:" check box. Enter "Status Update" string into the edit box.
  • Do the same for the Read Page.
  • Select the Properties tab and check the "Send form definition with item" check box.
  • Publish the form by selecting Tools - Forms - Publish Form As and typing "Status Update Request" string for the name.
  • Check whether the form works properly by sending it to yourself (File - New - Choose Form).
To create the Status Update form do the following:
  • Invoke a new mail Message Form.
  • Switch to the design mode.
  • While editing Compose Page resize the Message control.
  • In the appeared space introduce a new edit control and a label. You may need to press the "Control Toolbox" button to see available controls.
  • Introduce a new user defined field called "Status". Invoke the Field Chooser dialog (toolbar button). Press the New button and type in the "Status" string.
  • Associate the edit control with the "Status" field. Right click on the edit box, select Properties, go to Value tab and press the "Choose Field" button.
  • Switch to Read Page and remove the Message control from it. Select the Message control, the label and status edit control from the Compose Page and paste it onto the Read Page.
  • Select the Properties tab and check the "Send form definition with item" check box.
  • Publish it as Status Update form.
  • Test whether the form works properly by sending it to yourself.
To associate the Reply to Status Update Request with Status Update form:
  • Start editing the Status Update Request form by selecting Tools - Forms - Design a Form menu.
  • On the Actions tab disable the "Reply to All", "Forward" and "Reply to Folder" actions.
  • Modify the "Reply" action by specifying the "Status Update" form instead of "Standard message form".
  • Publish it again.
  • Check whether everything works by sending a Status Update Request to yourself and replying to it.
Writing a Visual Basic Script for an Outlook Form:

Let's add a trivial VBScript code to the form. For the sake of simplicity I am going to demonstrate here a very trivial form. I want my form to have one additional button. Pressing this button should invoke a Win32 MessageBox operation. By demonstrating this I hope to give you an idea how an Outlook form may interact with the operating system via Visual Basic script.

Create a button on a form in the way I have described above. Write Visual Basic script for the click event by going to Form - View Code and typing in the following:

Sub CommandButton1_Click
    Dim Response
    Response = MsgBox("You have pressed the button...", vbOK, "My Title")
End Sub

Clicking the CommandButton1 on the form will now invoke a standard message box.
 

[ Contents | Home ]

Send comments and suggestions to niko@wrconsulting.com
Copyright © 1997-1998 by Nik Okuntseff