Creating Properties on Items: The UserProperties Collection

[Previous] [Next]

The FormDescription object contains the form properties of the Outlook item. These properties correspond to the information contained in the Properties tab of an Outlook form in design mode. The following section describes some common tasks that you can perform on your Outlook item using the FormDescription object.

Retrieving the Script Text for an Item

You will want to be able to take the script text you have in an Outlook form and place that script in a central repository so that other Outlook developers can use it. With the ScriptText property of the FormDescription object for an item, you can retrieve the VBScript text from an Outlook item. The following code sample retrieves the VBScript from an Outlook item and adds it to the body of the message. Note that the ScriptText property is read-only.

     Sub CommandButton1_Click         txtScript = Item.FormDescription.ScriptText         item.Body = txtScript     End Sub 

Publishing Forms Programmatically

By using the PublishForm method of the FormDescription object, you can publish a form to any of the forms libraries, including the Personal Forms Library, the folder forms library, and the Organizational Forms Library. You might want to use this method so that you can e-mail a form as an .oft file to users who can then select which forms library they want to publish the forms into. The following code sample shows how you can retrieve an .oft file as an attachment in an item, create a new item using the CreateItemFromTemplate method and the .oft file, and then publish the .oft form to the personal forms Registry of the user. To test this code sample, save an Outlook form as a .oft file. Add it as an attachment to a message in design mode, and then add the code sample to the form. You should see the new form, named My Custom Form, in your Personal Forms Library.

     Sub CommandButton1_Click         set oAttachments = item.Attachments         set oOFTFile = oAttachments.Item(1)         txtFileLoc = oOFTFile.PathName & oOFTFile.FileName         set oForm = Application.CreateItemFromTemplate(txtFileLoc)         set oFormDescrip = oForm.FormDescription         oFormDescrip.Name = "My Custom Form"         oFormDescrip.PublishForm 2     End Sub 



Programming Microsoft Outlook and Microsoft Exchange
Programming Microsoft Outlook and Microsoft Exchange, Second Edition (DV-MPS Programming)
ISBN: 0735610193
EAN: 2147483647
Year: 2000
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net