Recipe 6.4. Creating a Mailbox DatabaseProblemYou wish to create one or more additional mailbox databases in an existing storage group. SolutionUsing a graphical user interface
Using VBScript' This code creates a new mailbox database in the first storage group ' of the target server and then mounts it. ' ------ SCRIPT CONFIGURATION ------ strServerName = "<serverName>" ' e.g., "BATMAN" strMDBName = "<databaseName>" ' e.g., "SpiffyNewDatabase" ' ------ END CONFIGURATION --------- Set theServer = CreateObject("CDOEXM.ExchangeServer") Set theMDB = CreateObject("CDOEXM.MailboxStoreDB") ' bind to the Exchange server and build the database URL theServer.DataSource.Open strServerName arrSG = theServer.StorageGroups theFirstSG = arrSG(0) strURL = "LDAP://" & theServer.DirectoryServer & "/cn=" & _ strMDBName & "," & theFirstSG wscript.echo "Creating database " & Chr(34) & strMDBName & _ Chr(34) & " on " & theFirstSG theMDB.Name = strMDBName theMDB.DataSource.SaveTo strURL WScript.Echo "Database created." theMDB.Mount WScript.Echo "Database mounted." DiscussionWhen you create a new mailbox database, Exchange generates a new, empty EDB file and fills it with the structures necessary to contain mailbox data. It also generates a matching STM file, which is empty until you start moving or creating mailboxes in the new store. By default, newly created stores aren't mounted; ESM will ask you if you want to mount the store, while you can use the Mount method on the mailbox store interface to mount a newly created store programmatically. The previous VBScript example uses the CDOEXM MailboxStoreDB interface to create a new database in the first SG on the server. You can easily modify the code to create databases in a named SG by specifying the URL of the SG instead of looking up the first one. If you do not wish to mount the store, simply comment out the last two lines of the VBScript example. See AlsoRecipe 6.5 for creating a public store, Recipe 6.6 for deleting a database, Recipes Recipe 6.7 and Recipe 6.8 for mounting or dismounting a database, and MSDN: IMailboxStoreDB |