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?
 
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
The new generation of project management tools

With monday.com’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?
0
 
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
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
All Courses

From novice to tech pro — start learning today.