2010-04-19

Notes on Developing Outlook 2003 Forms

I just finished developing a simple e-mail workflow system implemented using Outlook forms and VBScript and thought I should jot down some things that made development easier:

Configuring Your Development Environment

  • Disable Outlook Autosignature, otherwise your signature is inserted into the message object each time you create a new form and you cannot clear the text in the message object using the Form Designer. While you can clear the message object using VBScript using Item.Body = "", it's annoying to have so much noise during development.
  • If you use VBScript in your form definition, don't send the form definition in each item, otherwise you cannot run VBScript in your item. In the Form Designer's Properties tab, ensure that Send form definition with item is unchecked.
  • Each form definition has a unique Message Class. To ensure that you are opening items based on your form definition in Outlook, add the Message Class field into your Outlook View using the following steps:
    1. Select menu item View, Arrange By, Current View, Customize Current View. Outlook should open the Customize View dialog.
    2. In Customize View: dialog, select Fields... button. Outlook should open the Show Fields dialog.
    3. In Show Fields dialog, select All Mail Fields in the drop down list of available fields.
    4. Select and add Message Class to your view.
  • Create a desktop shortcut to use your form. Using the shortcut is faster than the alternative of using the menu item Tools, Forms, Choose Form and then picking your form from the Choose Form dialog. Plus, when you finish development and publish your form, you can send the shortcut file to your users.

One-Off Forms

If you have VBScript in your form definition, you must avoid making a one-off forms (i.e. an item which no longer references its form definition) because Outlook security does not allow VBScript to run in one-off forms. A one-off form can be identified if its Message Class is not the same as the form definition's and / or its size is much larger than expected. For instance, if you define a form named IPM.Note.Test, instances of this form should have the same message class and a size of about 5 to 6 Kbytes, while a one-off form may be called IPM.Note and / or have a size of in tens of Kbytes. If you think the rules for identify one-off items are a bit vague, read this.

There's a fair bit of documentation and discussion about one-off items online because that's how Outlook forms were first deployed before they were regarded as a security risk. I ignored one-off items (which seemed quite useless nowadays) and treated my form definition as my 'program'. During development, my form definition is published in Personal Folders and I always use that definition to create an item. I also found that using the form designer's Tools, Run This Form menu item creates one-off items.

VBScript Development

When writing VBScript for Outlook forms, you are stuck with the minimal Script Editor which doesn't have features such as highlighting syntax, auto-completion or a debugger; it's so minimal that it doesn't have a Save button or allow you to choose another font! At least changes in the Script Editor are always saved when you publish, so you can leave the Script Editor window open during a coding session.

Script Editor doesn't have a debugger, so you have to use the Outlook Script Debugger, which is the Web Debugger in read-only mode (!) that doesn't allow you to modify Outlook VBScript. The only silver lining that you can inspect objects and find out what properties they have in the script debugger.

Final Thoughts

Developing Outlook Forms with VBSCript was somewhat painful because of the lack of tool support. I hope the tips in this article would be useful for others starting on a similar project.

References