The attached sample includes two parts. One is the set of classes which can be reused as such for any C# DL Creation programs or may be extended. The second is the DL Creation functional part. This extensively uses CDO libraries for finding the necessary Server names, Site Names and the much needed Object Distinguished names for many entities.
The attached sample project can be downloaded here.
There are two classes available in the DLManagement namespaces which can be used in other C# programs. One class called DLManager, holds the utility functions which could be used for common operations required for creation or modifications of distribution list. The other class DistributionList, holds the data regarding the Distribution List.
These reusable classes can be downloaded here.
Some of the functions in this DLManager are described as below. All the functions in this class are static public members. So they can be used without instantiating this class.
- GetSites - This function can return a list of sites under an Exchange organization.
- GetOrganization - This function returns the Organization name for a CDO Address entry object
- IsLDAPEntryWithSlashes - Some properties of Exchange 5.5 need the entries with comma separated names in Object Distinguished Names. This function can be used to check if the entry contains slashes.
- GetHomeServer - This can be used to find the Home server for a particular distribution list.
- UpdateDL - This function can be used for either creating or modifying a DL. This takes care of setting all the above said properties, including adding the owner of the DL with its Security Descriptor.
- FindDL - This function can find and populate the details of a DL and return an object of DistributionList class.
- FindSMTPAddressing - This function gets the SMTP Addressing format for a site using ADO.
This class contains only data members to hold the properties of DLs. This can be used either way to retrieve or update the Distribution Lists using the DLManager class.
This application was written with Visual Studio .Net 2003. The Libraries used are as follows:
- Microsoft CDO 1.21 Libraries. This is available by default in your system if Outlook 2000 or above is installed.
- ADODB. This can be included from References --> Com --> Microsoft ActiveX Data Objects 2.6 & above.