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

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 vb.net but only a very basic understanding of using it to interact with active directory.
ParrTAsked:
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.

vb_jonasCommented:
"Re: CreateMailBox without using CDOEXM."
"Here is an example of using the ExchangeManagementShellWrapper if you are working with Exchange 2007 and AD.   "

http://directoryprogramming.net/forums/thread/2361.aspx
0
ParrTAuthor Commented:
This looks very promising - I will have a chance to try it out and get back to you. Thanks
0
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?
0
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.

vb_jonasCommented:
The Wrapper, which I missed to link to, is on this page: http://knicksmith.blogspot.com/2007_03_01_archive.html (if you need it in vb.net use http://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx)
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 vb.net.

http://forums.asp.net/t/1143988.aspx

(note that the routine is runnable from .net directly, but not via asp.net)
0
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.
0

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

Computer101
EE Admin
0
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.