Introduction to the Outlook Object Model


Regardless of the approach you choose to integrate your code with Outlook, you eventually will need to talk to the Outlook object model to get things done. This section introduces the Outlook object model. Chapter 10, "Working with Outlook Events," and Chapter 11, "Working with Outlook Objects," describe some of the most frequently used properties, methods, and events. This chapter also briefly examines another object model you can use with Outlook: Collaboration Data Objects (CDO).

The first step in learning the Outlook object model is getting an idea of the basic structure of the object model hierarchy. Figure 9.11 shows some of the most critical objects in the Outlook object model and their hierarchical relationships.

Figure 9.11. The basic hierarchy of the Outlook object model.


The Outlook object model has the notion of an Outlook item. An Outlook item is represented in the object model as an Object and can be cast to one of the 15 Outlook item types shown in Table 9.1. Some objects in the object model, such as the MAPIFolder object, contain an Items collection that can contain instances of any of the 15 Outlook item types; therefore, the folder may contain a mixture of MailItem objects, TaskRequestItem objects, and so on. When you iterate over a collection of Items, Outlook returns each item to you as an Object that you must cast to one of the 15 Outlook item types before using it.

Table 9.1. Outlook Item Types

Object

Description

ContactItem

A contact item typically found in the Contacts folder

DistListItem

A distribution list typically found in the Contacts folder

DocumentItem

A document that you have added to an Outlook folder by dragging and dropping it from the file system into the Outlook folder

JournalItem

A journal entry typically found in the Journal folder

MailItem

A mail message typically found in the Inbox folder

MeetingItem

A meeting request typically found in the Inbox folder

NoteItem

A note typically found in the Notes folder

PostItem

A post in an Outlook folder

RemoteItem

A mail message that has not yet been fully retrieved from the server but has the subject of the message, the received date and time, the sender, the size of the message, and the first 256 characters of the message body

ReportItem

A mail delivery report, such as a report when mail delivery failed, typically found in the Inbox folder

TaskItem

A task typically found in the Tasks folder

TaskRequestAcceptItem

A response to a TaskRequestItem typically found in the Inbox folder

TaskRequestDeclineItem

A response to a TaskRequestItem typically found in the Inbox folder

TaskRequestItem

A task request sent to another user typically found in the Inbox folder

TaskRequestUpdateItem

An update to a TaskRequestItem typically found in the Inbox folder


Another example of an Outlook object model object that is associated with multiple Outlook item types is the Inspector object. The Inspector object represents a window providing a detail view for one of the 15 Outlook item types. It could be providing a view on a NoteItem, a MeetingItem, and so on. Inspector has a CurrentItem property that returns the Outlook item it is displaying as an Object. You must cast the Object returned by CurrentItem to one of the Outlook item types in Table 9.1 before using it. Chapter 11, "Working with Outlook Objects," discusses Outlook items in more detail.

Figure 9.12 shows a more complete view of the Outlook object model. (All the objects considered Outlook items are gray.) Note in this diagram that the Inspector object and the Items object points to a gray circle, which represents any of the Outlook items colored gray.

Figure 9.12. Some of the objects in the Outlook object model. All gray objects are "Outlook items."





Visual Studio Tools for Office(c) Using Visual Basic 2005 with Excel, Word, Outlook, and InfoPath
Visual Studio Tools for Office: Using Visual Basic 2005 with Excel, Word, Outlook, and InfoPath
ISBN: 0321411757
EAN: 2147483647
Year: N/A
Pages: 221

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