+ Post New Thread
Results 1 to 10 of 10
Coding Thread, Programatically create mailbox with VB.NET in Coding and Web Development; Does anyone know of a way to use VB.net (Express 2008) to create an Exchange mailbox? I used to use ...
  1. #1

    Join Date
    Mar 2007
    Posts
    427
    Thank Post
    16
    Thanked 16 Times in 10 Posts
    Rep Power
    19

    Programatically create mailbox with VB.NET

    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.

  2. #2

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,867
    Thank Post
    412
    Thanked 778 Times in 651 Posts
    Rep Power
    182
    Guess you need to script the Exchange Powershell?

  3. #3

    Join Date
    Mar 2007
    Posts
    427
    Thank Post
    16
    Thanked 16 Times in 10 Posts
    Rep Power
    19
    Isn't the powershell just for Exchange 2007 onwards? I'm still running Exchange 2003

  4. #4

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,867
    Thank Post
    412
    Thanked 778 Times in 651 Posts
    Rep Power
    182
    Oh sorry, I saw "2008" and leapt to the keyboard

  5. #5

    Join Date
    Mar 2007
    Posts
    427
    Thank Post
    16
    Thanked 16 Times in 10 Posts
    Rep Power
    19
    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!

  6. #6
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42
    Can you use this:

    Code:
     	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.
    Last edited by apeo; 11th May 2010 at 02:22 PM. Reason: For got to define oUser.

  7. Thanks to apeo from:

    GoldenWonder (12th May 2010)

  8. #7

    Join Date
    Mar 2007
    Posts
    427
    Thank Post
    16
    Thanked 16 Times in 10 Posts
    Rep Power
    19
    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
    Last edited by GoldenWonder; 12th May 2010 at 01:31 PM.

  9. #8
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42
    No it doesnt create a mailbox, that gets created after. As for your mailbox sizes, if you're not using the defualt then:

    Code:
    		oUser.Put "mDBUseDefaults",False
    		oUser.Put "mDBStorageQuota",SetNumericValueHereForIssueWarning
    		oUser.Put "mDBOverHardQuotaLimit",SetNumericValueHereForProhibitSendAndReceive

  10. #9

    Join Date
    Mar 2007
    Posts
    427
    Thank Post
    16
    Thanked 16 Times in 10 Posts
    Rep Power
    19
    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)

  11. Thanks to GoldenWonder from:

    mac_shinobi (12th May 2010)

  12. #10
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42
    Quote Originally Posted by GoldenWonder View Post
    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.



SHARE:
+ Post New Thread

Similar Threads

  1. www.wordle.net/create doesnt work for student account
    By ithelp in forum Internet Related/Filtering/Firewall
    Replies: 6
    Last Post: 13th June 2014, 05:24 PM
  2. Replies: 7
    Last Post: 17th June 2010, 10:50 AM
  3. Tool to bulk create users / create single user easily?
    By reggiep in forum Windows Server 2008
    Replies: 9
    Last Post: 27th May 2010, 01:30 PM
  4. Setting folder owners programatically
    By localzuk in forum Windows Server 2000/2003
    Replies: 8
    Last Post: 19th February 2010, 07:33 PM
  5. JFolder::create: Could not create directory
    By speckytecky in forum EduGeek Joomla 1.5 Package
    Replies: 2
    Last Post: 9th November 2009, 08:19 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •