views:

807

answers:

1

I have a Windows Domain here that runs Exchange 2007, and I need to programmatically create new Mailing Lists.

From what I could gather so far, Exchange mailing lists are just normal AD Groups, so I mainly have to worry about the interaction with AD. I used the System.DirectoryService namespace to query AD, but I'm not sure what the correct way would be to create a Distribution Group here. Especially it has to be mail-enabled and show up in the Outlook address book, so I don't know if I need to invoke some magic to make sure Exchange picks up the new group?

Any pointers?

+1  A: 

The magic you need to invoke to make a distribution list for Exchange is PowerShell so you'll need to dive into the wonderful world of cmdlets. ;-)

You can create a distribution group in Active Directory by using System.DirectoryServices (or more easily if you're on .NET 3.5 through System.DirectoryServices.AccountManagement), add members and so on and then use the Enable-DistributionGroup-cmdlet to mail-enable the group.

You could also create the groups and mail-enable them at the same time by using the New-DistributionGroup-cmdlet.

Basically what the PowerShell cmdlets do is to set a bunch of Exchange-attributes on the Active Directory group such as proxyAddresses and so on. You might get away with setting some of these "manually" (ie by using System.DirectoryServices) but chances are you get some of them wrong. The supported (as in Microsoft Support-supported) way is through calling the cmdlets.

You're probably best off Googling on how to call PowerShell from you .NET program (I haven't found a really good article on it but it's pretty straight-forward once you get the hang of it) - MSDN has a sample and a section to get you started.

Per Noalt
Thanks. I was hoping there was a way to do that without needing access to the actual exchange server, but I guess I have to do it like that.
Michael Stum
There's no need for the code to run on the Exchange-servers. You can install the Exchange Management Console (which include the PowerShell cmdlets you need) on any server. The user account you use to create the distribution lists has to be a member of the Exchange Recipient Administrators group.
Per Noalt
Whoa, thanks, that is useful information! Getting a user account is rather easy in my organization, but installing stuff on production servers is not, so installing that management console on a server I "own" is great.
Michael Stum