Create Exchange 2003 mailbox

I am working on an app to simplify and standardize domain account creation and deletion.  I am using ADSI to create and delete domain accounts, change passwords, etc.  However, I want to be able to create mailboxes for the users too.  I have looked all over the web and found numerous articles that are similar, but haven't found the jackpot yet.

The problem occurs on the createmailbox line.  I get the following error:
Run-time error '438':
Object doesn't support this property or method

Can someone please help?

Thanks


I am using the following:

ADSICreateMailBoxEnabledUser "Mailbox Store (EXCHANGE2003)", "First Storage Group", "EXchange2003", _
                           "First Administrative Group", "ABC Company", "abcdomain.com", _
                           "testuser6", "Test", "User6"


Sub ADSICreateMailBoxEnabledUser _
  (MDBName, storageGroup, Server, adminGroup, Organization, DomainName, emailname, firstName, lastName)

'split the domain name to get the directory name for it
domainDN = "dc=" & Replace(DomainName, ".", ",dc=")

recip = "CN=" & emailname

' get the container
Set objContainer = GetObject("LDAP://CN=users," & domainDN)

' create a recipient
Set objUser = objContainer.Create("User", recip)
objUser.Put "samAccountName", emailname
objUser.Put "sn", lastName
objUser.Put "givenName", firstName
objUser.Put "userPrincipalName", emailname

objUser.SetInfo
objUser.SetPassword "12345"
objUser.AccountDisabled = False

Set objMailbox = objUser

                objMailbox.CreateMailbox "LDAP://CN=" & MDBName & _
                               ",CN=" & storageGroup & _
                               ",CN=InformationStore" & _
                               ",CN=" & Server & _
                               ",CN=Servers" & _
                               ",CN=" & adminGroup & _
                               ",CN=Administrative Groups" & _
                               ",CN=" & Organization & _
                               ",CN=Microsoft Exchange,CN=Services" & _
                               ",CN=Configuration," & domainDN

objUser.SetInfo

End Sub
myeritAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jimbobmcgeeCommented:
jimbobmcgeeCommented:
Disregard, that is for setting up accounts a local machine...
myeritAuthor Commented:
J.,

That may be true, however, it seems from the articles I am finding that it is possible.  I believe I am simply doing something wrong.

Thanks
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

jimbobmcgeeCommented:
http://www.codecomments.com/Windows_Server_Scripting/message171717.html has an example.  Why have you chosen to set objMailbox = objUser.  I think you may be better off with just objUser.CreateMailbox...

J.
PreeceCommented:
If you haven't done so already, I would start by inspecting the values of your variables:

debug.print MDBName
debug.print storageGroup
debug.print Server
debug.print adminGroup
debug.print Organization
debug.print domainDN

PreeceCommented:
Do the debug.prints just before the CreateMailbox code.

Your code seems to mimick the example on this page:

http://www.internetaccessmonitor.com/eng/products/articles/Scripting_Exchange_Using_VBScript_and_ADSI_Part_2/Scripting_Exchange_Using_VBScript_and_ADSI_Part_2.php

Which has the objMailbox = objUser

Preece

myeritAuthor Commented:
Using objuser.createmailbox raises the same error.
myeritAuthor Commented:
Right, this code snippet is all over the web.  I am attempting to make it work, but with no luck.
PreeceCommented:
Hmmmm....are you variables properly populated?

Preece
myeritAuthor Commented:
As best I can tell, they are all correct.

I believe the problem is rather related to not having a reference included because the method is not being recognized.
PreeceCommented:
Duh, I just saw the call:

ADSICreateMailBoxEnabledUser "Mailbox Store (EXCHANGE2003)", "First Storage Group", "EXchange2003", _
                           "First Administrative Group", "ABC Company", "abcdomain.com", _
                           "testuser6", "Test", "User6"

So, your variables are being set properly.  I am suprised that data types are not declared, but this is VBS and I mostly do VB.

In VB, the sub could be declared as:

Sub ADSICreateMailBoxEnabledUser _
  (MDBName as String, storageGroup as String, Server as String, adminGroup as String, Organization as String, DomainName as String, emailname as String, firstName as String, lastName as String)

If you are not seeing the method, then maybe the requisite libraries are not loaded.  Must you have Exchange installed on the pc attempting to execute this code?

Preece
myeritAuthor Commented:
I agree.  The question is, what libraries should be loaded.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
myeritAuthor Commented:
preece,

I am still working on this.  So far no luck.

Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.