How to mail enable an active directory account for exchange 2007 in

hi there, I have found several sources for code to mail-enable active directory accounts but they all use th Microsoft CDO for Exchange Management Library (aka CDOEXM).

Unfortunately this does not work with Exchange 2007.

I need some example code that will work with 2007. Please be explicit about the references I need to add, and which imports I need. I have a reasonable knowledge of but only a very basic understanding of using it to interact with active directory.
Who is Participating?
"Re: CreateMailBox without using CDOEXM."
"Here is an example of using the ExchangeManagementShellWrapper if you are working with Exchange 2007 and AD.   "
ParrTAuthor Commented:
This looks very promising - I will have a chance to try it out and get back to you. Thanks
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

ParrTAuthor Commented:
Ok - I have tried to get the code to work. After a little googling I have discovered that some of the objects reside in the System.Management.Automation namespace (downloaded as part of the powershell sdk). However I cannot find out what namespace I need for

rootDSE or ExchangeManagementShellWrapper in the lines:

  Dim dnsHostFQDName As String = rootDSE.Properties("dnsHostName")(0)

  Dim ems As ExchangeManagementShellWrapper = ExchangeManagementShellWrapper.Instance

Do I need to download some other dlls?

I am also unsure what the value of the MailDB variable should be - my guess is the name of the server running exchange?
The Wrapper, which I missed to link to, is on this page: (if you need it in use
And MailDB  = "servername\databasename"
rootDSE is needed only to get the FQDN, so you can set it directly in
Dim dnsHostFQDName As String = "servername.mydomain.local"

However - after I sent you my last comment I've found this solution which seems more accurate (also needs System.Management.Automation). I haven't tested it myself. Use the developerfusion link above if you need to translate it to

(note that the routine is runnable from .net directly, but not via
ParrTAuthor Commented:
I get the following error at the line:

 Dim snampInfo As PSSnapInInfo = runspaceConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", snapEX)

The error is:

No Windows PowerShell Snap-ins are available for version 1.

I have also tried to use Get-Help Enable-Mailbox in the powershell command line interface but it tells me that enable-mailbox is not recognised.
Forced accept.

EE Admin
All Courses

From novice to tech pro — start learning today.