Introduction to the Outlook Object Model

Regardless of the approach you choose to integrate your code with Outlook, you will eventually 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 called Collaboration Data Objects (CDO).

The Object Hierarchy of the Outlook Object Model

The first step in starting to learn the Outlook object model is getting an idea for 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 relationship.

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 15 different 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 typestherefore, 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 different Outlook item types. It could be providing a view on a NoteItem, a MeetingItem, and so forth. 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 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 colored 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 modelgray objects are all "Outlook items."


Part One. An Introduction to VSTO

An Introduction to Office Programming

Introduction to Office Solutions

Part Two. Office Programming in .NET

Programming Excel

Working with Excel Events

Working with Excel Objects

Programming Word

Working with Word Events

Working with Word Objects

Programming Outlook

Working with Outlook Events

Working with Outlook Objects

Introduction to InfoPath

Part Three. Office Programming in VSTO

The VSTO Programming Model

Using Windows Forms in VSTO

Working with Actions Pane

Working with Smart Tags in VSTO

VSTO Data Programming

Server Data Scenarios

.NET Code Security

Deployment

Part Four. Advanced Office Programming

Working with XML in Excel

Working with XML in Word

Developing COM Add-Ins for Word and Excel

Creating Outlook Add-Ins with VSTO



Visual Studio Tools for Office(c) Using C# with Excel, Word, Outlook, and InfoPath
Visual Studio Tools for Office(c) Using C# with Excel, Word, Outlook, and InfoPath
ISBN: 321334884
EAN: N/A
Year: N/A
Pages: 214

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