' This script was originally published in the Exchange Cookbook, ' (http://www.exchangebookcook.com). Written by Paul Robichaux, ' Missy Koslosky, and Devin Ganger. Redistributed with permission ' of the publisher, O'Reilly & Associates. ' This code creates a folder with the specified name at the top level ' of the MAPI TLH. ' ------ SCRIPT CONFIGURATION ------ strFolderName = "" ' e.g., "Bad Jokes" ' ------ END CONFIGURATION --------- ' Get the default domain name. This is not necessarily ' the same as the AD domain name, which is why we have to ' get it from the recipient policy object Set objDefaultPolicy = GetObject( _ "LDAP:///cn=default policy,cn=recipient policies," &_ "cn=,cn=microsoft exchange,cn=services," &_ "cn=configuration,dc=,dc=") ' get all of the proxy addresses in the default recipient ' policy. Find the default SMTP policy and that'll tell us ' what the default Exchange domain is strProxies = objDefaultPolicy.Get("gatewayProxy") For Each proxyAddr In strProxies If (Left(proxyAddr, 5) = "SMTP:") Then strStorageName = Right(proxyAddr, Len(proxyAddr)-InStr(proxyAddr, "@")) End if Next ' Build the path to the storage object. strStorageName = "file://./backofficestorage/" + strStorageName + "/" ' Create the folder.object strFolderPath = strStorageName + "public folders/" + strFolderName Set theFolder = CreateObject("cdo.folder") ' Set the folder properties. With theFolder .Description = "Root folder for " + strFolderName .ContentClass = "urn:content-classes:folder" .fields("http://schemas.microsoft.com/exchange" &_ "/outlook/outlookfolderclass") = _ "IPF.Folder" .Fields.Update .DataSource.SaveTo strFolderPath End With WScript.Echo "Done creating folders."