Creating a Task
To create a
task, add a Message object to a folder’s Messages collection,
setting the Type property of the Message object to
"IPM.Task
“. A task can be created in
any folder, but the most logical choice is the user’s Tasks
folder, as shown here:
' 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 ' Add a new task. Set CdoMessage = CdoMessages.Add(Subject:="Buy milk", Type:="IPM.Task") ' Save the new item. CdoMessage.Update
The body text can be set, if desired, by passing a string in the Text parameter of the Messages collection’s Add method, or by setting the Text property of the Message object itself.
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.