Creating MailBox Store programatically


                    Le Café Central de
Deva              

                                 
                                 ..... Deva blogs!!




 

 

Creating MailBox Store programatically

  • Comments 1

I have found this wonderful piece of code(Visual Basic 6.0), used to create mailbox store.

'//////////////////////////////////////////////////////////////////////////////////
'// Name:       CreateNewMailboxStoreDB
'// Purpose:    To create a new Mailbox Store (MDB) with a given name
'// Input:      strMDBName            = contains the name of the new MDB to be created
'//             blnMount                    = True if the new MDB will be mounted after creation or False if the new MDB will not be mounted
'//             strComputerName       = contains the name of the Exchange 2000 server
'//             strSGName (Optional) = contains the name of the storage group to create the new MDB in; if it is empty then the new MDB will be created in the
'//                                                  default Storage Group
'//             strMDBUrl (Optional ByRef) = contains the URL to the new MDB created;
'//
'//////////////////////////////////////////////////////////////////////////////////

Public Sub CreateNewMailboxStoreDB(ByVal strMDBName As String, ByVal strComputerName As String, Optional ByVal blnMount As Boolean, _
                                                          Optional ByVal strSGName As String, Optional ByRef strMDBUrl As String)

    Dim iServer         As New CDOEXM.ExchangeServer
    Dim iMDB            As New CDOEXM.MailboxStoreDB
    Dim arrStGroup()    As Variant
    Dim i               As Integer
    Dim strTemp         As String


    ' Set the name of the MailboxStoreDB
    iMDB.Name = strMDBName

    ' Bind to the Exchange Server
    iServer.DataSource.Open strComputerName

    ' Start to build the URL to the MailboxStoreDB - first part
    strTemp = "LDAP://" & iServer.DirectoryServer & "/" & "cn=" & strMDBName & ","

    ' Set variant array to the ExchangeServer.StorageGroups
    arrStGroup = iServer.StorageGroups

    ' Look in the StorageGroups array if the StorageGroup with strSGName exists
    If strSGName = "" Then
        ' Finish to build the URL to the MailboxStoreDB - add last part
        strMDBUrl = strTemp & iServer.StorageGroups(0)
    Else
        For i = 0 To UBound(arrStGroup)
            If InStr(1, UCase(arrStGroup(i)), UCase(strSGName)) <> 0 Then
                strMDBUrl = arrStGroup(i)
            End If
        Next
        If strMDBUrl <> "" Then
            ' Finish to build the URL to the MailboxStoreDB - add last part
            strMDBUrl = strTemp & strMDBUrl
        End If
    End If

    ' Save the New MailboxStoreDB
    iMDB.DataSource.SaveTo strMDBUrl

    ' Mount the MailboxStoreDB if blnMount is True
    If blnMount = True Then
        iMDB.Mount
    End If

    ' Cleanup
    Set iServer = Nothing
    Set iMDB = Nothing

End Sub

  • I have found this wonderful piece of code(Visual Basic 6.0), used to create mailbox store. &#39;////

Page 1 of 1 (1 items)
Blog - Post Feedback Form(CAPTCHA)
Leave a Comment
  • Post