Share via


Creating a Folder Tree

Creating a Folder Tree

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The following example creates a folder tree in the Exchange store. See Managing Exchange Server for an explanation of the folder tree.

Visual Basic

'//////////////////////////////////////////////////////////////////////////////////
'// Name:       CreatePublicFolderTree
'// Purpose:    To create a new PublicFolderTree with a given name
'// Input:      strFolderName = contains the name of the new folder to be created
'//             strAdminGroup = contains the name of the Admin Group to place the Folder Tree in
'//             strOrganization = contains the name of the Exchange Organization
'//             strDomain = contains the domain components of the LDAP path, eg: "DC=example,DC=com"
'//             strFolderUrl (Optional ByRef) = contains the URL to the new folder created;
'//
'//////////////////////////////////////////////////////////////////////////////////

Public Sub CreatePublicFolderTree(ByVal strFolderName As String, _
                                             ByVal strAdminGroup As String, _
                                             ByVal strOrganization As String, _
                                             ByVal strDomain As String, _
                                             Optional ByRef strFolderURL As String)
    On Error Resume Next
    Dim iServer         As New CDOEXM.ExchangeServer
    Dim iPFTree         As New CDOEXM.FolderTree

    ' Build the URL to the PublicFolderTree
    strFolderURL = "LDAP://CN=" + strFolderName + _
                         ",CN=Folder Hierarchies" + _
                         ",CN=" + strAdminGroup + _
                         ",CN=Administrative Groups" + _
                         ",CN=" + strOrganization + _
                         ",CN=Microsoft Exchange,CN=Services,CN=Configuration," + strDomain

    ' Set the name of the PublicFolderTree
    iPFTree.name = strFolderName

    ' Save the PublicFolderTree
    iPFTree.DataSource.SaveTo strFolderURL

    ' Cleanup
    Set iServer = Nothing
    Set iPFTree = Nothing

End Sub


The preceding subroutine calls GetFolderTreeURL to build a proper URL for creating a folder tree. See Retrieving Folder Tree URLs for a description of GetFolderTreeURL().

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.