GoldenWonder Posted May 11, 2010 Posted May 11, 2010 Does anyone know of a way to use VB.net (Express 2008) to create an Exchange mailbox? I used to use the old CDO (cdo.dll,cdoexm.dll) methods but these don't seem to work on Server 2008. Searching around the web always seems to come back to the CDO object, but surely there is another method available in .net that doesn't rely on dlls from 2001! Another issue is that I can't install the Exchange 2003 Management tools onto 2008 Server which causes further problems.
powdarrmonkey Posted May 11, 2010 Posted May 11, 2010 Guess you need to script the Exchange Powershell?
GoldenWonder Posted May 11, 2010 Author Posted May 11, 2010 Isn't the powershell just for Exchange 2007 onwards? I'm still running Exchange 2003
powdarrmonkey Posted May 11, 2010 Posted May 11, 2010 Oh sorry, I saw "2008" and leapt to the keyboard
GoldenWonder Posted May 11, 2010 Author Posted May 11, 2010 Nice idea though! Shame MS haven't provided the 2003 Exchange Management Tools for Server 2008. If I could register the cdoexm.dll on Server 2008 I would be OK as this would give me the references required. I'm amazed there doesn't seem to be a proper,.NET, MS approved way of creating mailboxes!
apeo Posted May 11, 2010 Posted May 11, 2010 (edited) Can you use this: strAccountName = "ACCOUNTNAME" 'Get parent container Set oContainer = GetObject("LDAP://" & strNetworkLdap) 'Create user Set oUser = oContainer.Create("User","CN=" & strAccountName) strHomeMDB = "CN=Mailbox Store (EXCHANGE),CN=First Storage Group,CN=InformationStore," & _ "CN=EXCHANGE,CN=Servers,CN=First Administrative Group,CN=Administrative Groups," & _ "CN=YOUR Storage GROUP,CN=Microsoft Exchange,CN=Services," & _ "CN=Configuration,DC=YOUR,DC=DOMAIN" oUser.Put "HomeMDB", strHomeMDB oUser.Put "mailNickname", strAccountName 'Set Exchange Alias to Username oUser.SetInfo This will create a user. Edited May 11, 2010 by apeo For got to define oUser. 1
GoldenWonder Posted May 12, 2010 Author Posted May 12, 2010 (edited) I think that code just sets their mailbox location - it creates the user and set their Exchange details but doesn't actually create the mailbox itself. I use similar code to the above to create the user account and set their details, but use references to the CDOEMX.IMailboxStore object to actually create mailboxs and set the storage limits. This simply won't work in Server 2008 and MS seem to offer no alternative. EDIT: Actually I'm wrong that has worked (blame my poor typing!) - nice one! All I need to do now is find a way to set the mailbox sizes Edited May 12, 2010 by GoldenWonder
apeo Posted May 12, 2010 Posted May 12, 2010 No it doesnt create a mailbox, that gets created after. As for your mailbox sizes, if you're not using the defualt then: oUser.Put "mDBUseDefaults",False oUser.Put "mDBStorageQuota",SetNumericValueHereForIssueWarning oUser.Put "mDBOverHardQuotaLimit",SetNumericValueHereForProhibitSendAndReceive
GoldenWonder Posted May 12, 2010 Author Posted May 12, 2010 Ahh now thats working a treat! I had a few problems when setting the mDB... values, but checking ADSIEdit shows that these values must be integers (I was using Long) - and now it all seems to work! Brilliant stuff, thanks for everyones help on this. By the way, does the mailbox not get created until the users first login? (thats my understanding anyway) 1
apeo Posted May 14, 2010 Posted May 14, 2010 Ahh now thats working a treat! I had a few problems when setting the mDB... values, but checking ADSIEdit shows that these values must be integers (I was using Long) - and now it all seems to work! Brilliant stuff, thanks for everyones help on this. By the way, does the mailbox not get created until the users first login? (thats my understanding anyway) Yeah i should have said its an iteger, its basically the same value you put in when you do it manually. Glad you got it to work. My understanding is the same, the details are put into AD but the Mailbox isnt created/finish properly until they login to their email account the first time. I think up till that point its there only in part. That being said, sometimes theres a delay and you find that users cant login right away. This isnt a problem, you can either wait a bit and it updates itself or you can open up the mailbox within your account in Outlook.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now