Creating Exchange 5.5 Mail Box and Distribution List

Dim objNamespaceCache As INamespaceCache
Dim objNamespace As INamespace
Dim strUserName As String
Dim strPassword As String
Dim strEncrPassword As String
Dim stdDMSName As String
Dim strExchangeServer As String
Dim objContainer As IADsContainer

strExchangeServer = "Server"
stdDMSName = "DMSName"
strUserName = "Domain\User"
strPassword = "password"

Set objNamespaceCache = New XNamespaceCache
Set objNamespace = objNamespaceCache.Get(stdDMSName, strExchangeServer, strUserName, strPassword)
Set objContainer = objNamespace.GetObject("LDAP://Server/cn=container,ou=site,o=org")

'Mailbox Creation
Dim objNewMailBox As IADs
Set objNewMailBox = objContainer.Create("organizationalPerson", "cn=NewMailBox")
objNewMailBox.Put "mailPreferenceOption", 0
objNewMailBox.Put "givenName", "FirstName"
objNewMailBox.Put "sn", "LastName"
objNewMailBox.Put "cn", "DisplayName"
objNewMailBox.Put "MAPI-Recipient", True
objNewMailBox.SetInfo

'Distribution List Creation
Dim objNewDL As IADs
Set objNewDL = objContainer.Create("groupOfNames", "cn=NewDL")

'Set the props
objNewDL.Put "cn", "DL DisplayName"
objNewDL.Put "owner", "cn=NewMailBox,cn=container,ou=site,o=org"
objNewDL.SetInfo

objContainer = Nothing
objNewMailBox = Nothing
objNewDL = Nothing
objNamespace = Nothing
objNamespaceCache = Nothing