Reading Tasks

From CDO’s point of view, tasks are stored as Message objects. It’s easy to tell when a Message object represents a task: its Type property is set to "IPM.Task“. It is this value that signifies to Microsoft Outlook, for example, to display an item using the Task form rather than the Message form.

Some points about accessing task items through CDO:

  • A task’s description is found in the Message object’s Subject property.

  • Unlike message items, the Text property of a Message object representing a task item is typically left empty, though it doesn’t have to be.

  • Task items can accommodate rich text. To do this through CDO, use the CdoHelper component introduced in Chapter 6.

  • Task items can accommodate attachments. This is done in the same way as it is with email message items, as discussed in Chapter 6.

  • Most of the really useful task information is stored in named properties, and Microsoft doesn’t document the names (argh!). This is discussed in more detail later in this chapter.

The code in Example 9-1 loads a list box with the task descriptions from the user’s Tasks folder. Sample output is shown in Figure 9-1.

Example 9-1. Loading a List Box with Tasks

Private Sub ShowTasks( ) ' gCdoSession previously Dim'ed, Set, and logged on. Dim CdoFolder As MAPI.Folder Dim CdoMessages As MAPI.Messages Dim CdoMessage As MAPI.Message ' Get the Tasks folder. Set CdoFolder = gCdoSession.GetDefaultFolder(CdoDefaultFolderTasks) ' Get the collection of tasks. Set CdoMessages = CdoFolder.Messages ...

Get CDO & MAPI Programming with Visual Basic: 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.