Microsoft Office Tutorials and References
In Depth Information
For example, the GetNamespace() method is part of the Outlook Application object. Full
syntax for this would be
but because of the implicit availability of the Application reference, you can write it like this:
The Namespace Object
Another high-level object in the Outlook Object Model is the Namespace object. It exists because
Outlook was designed to be usable with different kinds of data, each of which would be identified
by its own namespace. So far, only one kind of data is supported in Outlook, MAPI data (MAPI
stands for Messaging Application Programming Interface). Therefore there is only one namespace.
Though it seems like unnecessary effort, you must use this namespace when accessing email and
other items in Outlook. In many of the code examples in this and later chapters, you’ll see a few
lines of code like this:
Dim MyOutlookNamespace As Outlook.Namespace
Set MyOutlookNamespace = GetNamespace(“MAPI”)
Then, the Namespace object is used when accessing mail and other folders:
Set f = MyOutlookNS.GetDefaultFolder(olFolderInbox)
Getting References to Outlook Folders
Outlook items are all stored in folders, and before you can work with items you need to get a
reference to the containing folder. Outlook has two types of folders: the default folders and user-created
Referencing Default Folders
A default folder is one of the folders that is part of Outlook and cannot be deleted, such as the
Inbox, the Deleted Items folder, and the Notes folder. To get a reference to one of these folders,
which are represented by the Folder object, you use the GetDefaultFolder() method. This
method takes one argument that specifies the folder you are interested in:
Dim folder As Outlook.Folder
Set folder = MyOutlookNamespace.GetDefaultFolder( foldertype )
The foldertype argument can be one of the named constants listed in Table 24.1, along with
the folder each returns. This table lists only those constants used frequently; you can refer to
online help for the complete list.
Search JabSto ::

Custom Search