The Outlook Object Model

Although VBScript allows you only to program an Outlook form, it nevertheless gives you relatively complete access to the Outlook object model, which is shown in Figure 6.6. Since the object model is fairly large, we’ll focus only on some of its highlights here, and in particular on those objects that you are most likely to use when programming an Outlook form. You can explore the Outlook object model by opening the object browser in the VBScript editor, or by using the Object Browser included with the VBA integrated development environment.

The Outlook 2000 object model

Figure 6-6.  The Outlook 2000 object model

Note that when you’re attempting to access the Outlook object model using VBScript, the context of your script is the current item, which can be represented by the Item keyword. In other words, as your script is executing, the Item object is the current object; to access other objects in the object model, you have to navigate to them from the Item object.

This also means that a reference to the current item is assumed in any attempt to navigate the object model or access a particular object, property, or method. For example, the code:

MsgBox Item.Application.Version

is identical to the code:

MsgBox Application.Version

This second line of code is interpreted as an attempt to retrieve the value of the Application object of the current item, and to retrieve its Version property.

If you’re ...

Get VBScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.