Skip to Content
CDO & MAPI Programming with Visual Basic:
book

CDO & MAPI Programming with Visual Basic:

by Dave Grundgeiger
October 2000
Intermediate to advanced
384 pages
10h 22m
English
O'Reilly Media, Inc.
Content preview from CDO & MAPI Programming with Visual Basic:

Working with Folders

An email client application can perform a number of tasks with Folder objects. An obvious one is to locate a folder of interest within the folder hierarchy. The Session object maintains references to the Inbox and Outbox folders of the default InfoStore, making it easy to obtain either. However, the Session object doesn’t maintain references to other common folders, so it’s useful to implement a generic function for finding a folder by name. Example 7-1 shows such a function.

Example 7-1. Finding a Folder Object by Name

Public Function GetFolderByName( _ ByVal CdoSession As MAPI.Session, _ ByVal strFolderName As String, _ Optional ByVal CdoFolderParent As MAPI.Folder = Nothing, _ Optional ByVal bCreate As Boolean = True _ ) As MAPI.Folder Dim CdoInfoStore As MAPI.InfoStore Dim CdoFolderRoot As MAPI.Folder Dim CdoFolders As MAPI.Folders Dim CdoFolder As MAPI.Folder Dim bFound As Boolean ' If the parent folder wasn't passed in, then use the root ' folder of the default InfoStore. If CdoFolderParent Is Nothing Then ' Get the Folders collection from the default InfoStore. Set CdoInfoStore = CdoSession.GetInfoStore Set CdoFolderRoot = CdoInfoStore.RootFolder Set CdoFolders = CdoFolderRoot.Folders Else ' Get the Folders collection from the parent folder. Set CdoFolders = CdoFolderParent.Folders End If ' Loop through the folders in the collection until the ' desired folder is found. bFound = False Set CdoFolder = CdoFolders.GetFirst Do While (Not bFound) And Not ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Excel® 2007 VBA Programmer's Reference

Excel® 2007 VBA Programmer's Reference

John Green, Stephen Bullen, Rob Bovey, Michael Alexander
COM Programming with Microsoft® .NET

COM Programming with Microsoft® .NET

John Paul Mueller, Julian Templeman

Publisher Resources

ISBN: 156592665XSupplemental ContentCatalog PageErrata