Folders Property (Folder Object)

Exchange Server 2003

Topic Last Modified: 2004-06-09

The Folders property returns a Folders collection of subfolders within the folder. Read-only.


Object (Folders collection)

Although the Folders property itself is read-only, the collection it returns can be accessed in the normal manner through its Add and Delete methods, and the properties on its member Folder objects retain their respective read/write or read-only accessibility.

The Microsoft® Schedule+ appointment folder is not implemented in the same way as Microsoft® Outlook® folders and CDO folders. In particular, it does not have subfolders. An attempt to read the Folders property on the Schedule+ appointment folder returns CdoE_NO_SUPPORT.

The Folders property does not correspond to a MAPI property and cannot be rendered into HTML hypertext by the CDO Rendering Library.

This code fragment uses a recursive function to list the names of all subfolders of the specified folder:

Set objFolder = objSession.Inbox
' assume objFolder is valid
If CdoFolder = objFolder.Class Then ' verify it's a Folder object
   ListFolders objFolder ' use current global folder
' *** must call ListFolders withOUT parentheses, or else VB evaluates
' *** objFolder for its default property and passes objFolder.Messages
End If

' subroutine to list folders
Sub ListFolders(objParentFolder As Folder)
Dim objFoldersColl As Folders ' the child Folders collection
Dim objOneSubfolder As Folder 'a single Folder object
' set up error handler here
If Not objParentFolder Is Nothing Then
   MsgBox ("Folder name = " & objParentFolder.Name)
   Set objFoldersColl = objParentFolder.Folders
   If Not objFoldersColl Is Nothing Then ' there are child folders
      Set objOneSubfolder = objFoldersColl.GetFirst
      While Not objOneSubfolder Is Nothing ' loop through all children
         ListFolders objOneSubfolder ' must call wihout parentheses
         Set objOneSubfolder = objFoldersColl.GetNext
   End If
   Exit Sub
End If
' error handler here
End Sub