Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  Windows Development  »  Interop  »  Using C# to Create Distribution Lists
Using C# to Create Distribution Lists
by Muthukumar V | Published  05/10/2005 | Interop | Rating:
Muthukumar V
I am a Programmer in C++/VC++/C#. http://www.codersource.net 

View all articles by Muthukumar V...
Introduction

Home Page: http://www.codersource.net

  A Distribution List can be created like a normal mailbox with only a small difference.  This is that it can contain other mailboxes and distribution lists as members for itself. A mailbox or a distribution list is created below the Site Container of an Exchange domain. Once this entity is created depending on the replication timing, it becomes available on the Global Address List. This article tries to explain how to access the exchange domain and create a distribution list and create a distribution list programmatically using C# and Active Directory.

   Typical Issues that arise when someone programmatically tries to create the distribution list is that they cannot create a distribution list if they are not connected to the server on the site. i.e., If the user of Site1 tries to modify the details of a Distribution List on a different site say Site2 through the program, this won't be permitted. In this case the user with administrator rights must logon again using the server which hosts the corresponding site.

   Some other issues could be like finding all the connected Sites, Servers in an exchange environment. Also parsing the address book for some data using ADSI will likely to be slow. This article and the sample program use an approach combining both CDO and ADSI for creating distribution list with C#. This can easily be extended to creating mailboxes also.

Microsoft Exchange Architecture:

A Microsoft Exchange Environment can be configured to contain many sites under a domain. Though all of us might know this, this might be useful if we do a small preview of the basic details.

If a domain Microsoft.com is available as root, there could be many sites configured under the root domain of Microsoft.com like London, Newyork, Moscow. This has many advantages.

  • Easier localized management of users.
  • Logical classification of employees/users
  • Faster access because of localized placement of servers
  • All the mail addresses can be accessed together through a Global Address List.
  • and many more..

   And apart from this each of the domains can contain many servers which can handle the mail delivery mechanisms to share the load of the site under the domain. The architecture looks something like this.

  Typically if a user wants to modify any Distribution List members or any other data of Distribution list the user has to have the relevant admin rights. The Microsoft Exchange Administrator program is usually used to make  the modifications on these data on Distribution List. Occasionally Outlook can also be used to modify the membership of the Distribution List, provided the logged on user is either an administrator or he is the owner of the distribution List. But whatever may be the case, cross site modifications are not allowed. So the program has to be careful to use the correct server in order to do the same.

Comments    Submit Comment

Comment #1  (Posted by an unknown user on 10/07/2005)
Rating
good
 
Comment #2  (Posted by David Smith on 09/15/2006)
Rating
As it came, it didn't work. I added a reference to Interop.MAPI, the added 'using MAPI;', at which point it built successfully - but when run, nothing happened. When I checked, there was no startup object, so I selected the form. Same result - nothing came up.

So, my question is - did you EVER run this yourself?
 
Comment #3  (Posted by an unknown user on 09/15/2006)
Rating
There is a fairly detailed explaination, but the example didn't work
 
Comment #4  (Posted by an unknown user on 09/15/2006)
Rating
Excellent work. Thanks.
 
Comment #5  (Posted by an unknown user on 09/29/2006)
Rating
Sounds very interesting...but I can't get it to work. I get an error beginning with..."System.Runtime.InteropServices.COMException (0x8007203A): The server is not operational at...[etc]"

Does anyone know what is needed to make it work?
 
Comment #6  (Posted by an unknown user on 10/02/2006)
Rating
Good One. Concepts are explained very well.
 
Comment #7  (Posted by David on 10/17/2006)
Rating
Nice conceptual level explanation. ought to check the sample.
 
Comment #8  (Posted by Ian Dunn on 07/12/2007)
Rating
After jumping through some hoops to try to get it to compile, I get this exception when trying to do gSession.Logon:

System.Runtime.InteropServices.COMException (0x80040111): [Collaboration Data Objects - [MAPI_E_LOGON_FAILED(80040111)]]

Are there some specific security settings needed for anonymous logon?
 
Comment #9  (Posted by an unknown user on 03/28/2008)
Rating
Can you add another method that will retreive all distribution list name from exhanger server. Adding and removing user to the distribution list.
 
Sponsored Links