Visual Studio Tools for Office: Using Visual Basic 2005 with Excel, Word, Outlook, and InfoPath
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.
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."
|
Категории