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?
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.

"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
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?
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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.

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
Forced accept.

EE Admin
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
.NET Programming

From novice to tech pro — start learning today.