locked
Calling CDOEXM.dll from an ASP.NET web page RRS feed

  • Question

  • User-1732200463 posted

    Hello Forum Folks,

    If I picked the wrong category to put this problem in, I kindly apologise in advance.

    Synopsis:  I have an ASP.NET web application in C#.  Under certain conditions, it will create security groups in AD.  I need to email-enable these AD groups.  It is my understanding that this can be accomplished through CDOEXM with the following example code:

     //Bind to group using account with permission to mail enable objects
    DirectoryEntry ADGroup = new DirectoryEntry("LDAP://mydc.com/"+GroupDN,"svcacctusername", "svcacctpassword");
    //Cast Native Object to CDOEXM
    IMailRecipient MailRecip = (IMailRecipient)ADGroup.NativeObject;
    //Mail Enable
    MailRecip.MailEnable(null);
    //Save Object Changes
    ADGroup.CommitChanges();

    Because CDOEXM only resides on Exchange servers, this code must be run on an exchange server.  Theoretically, I need to create a DCOM wrapper with the above code, place it somewhere on the exchange server then call said code from the ASP.NET code on the IIS server.  Is that the correct way to do this, or is there a better way?

    For a CDOEXM refresher:cdoexm.dll

    First problem: creating the DCOM wrapper.  I copied the CDOEXM.dll to my machine then tried to use the 'Add Reference' in Visual Studio to import it.  It fails with this message - "A reference to 'D:\filepath\codexm.dll could not be added.  Please make sure that the file is accessible, and that it is a valid assembly or COM component".  I believe I need to register this dll with my system first, but I'm not sure that is possible because it seems that I need Exchange Administrative Tools installed as well and I assume that requires Exchange, which I don't think I can get installed on my dev box.  Is there another way to develop this code?

    Second problem:  My ASP.NET app is on one server and Exchange is on another.  How do I call the DCOM wrapper from a different machine?  Where do I place the DCOM wrapper code?  What do I need to do to make it accessible from another machine?

    Thanks in advance for your input

    --awclements



    Wednesday, June 24, 2009 7:25 PM

All replies

  • User-1732200463 posted

    It appears that in order to do this, I need to setup a Windows 2003 server with SP3 and Visual Studio - install Exchange 2003 on it, install the management tools and then add the references in the correct order to VS and I might be able to get it to compile.  Apparantly I'm not the only one with this problem:  http://www.velocityreviews.com/forums/t87995-cdoexm-error-adding-assembly.html

    If Microsoft is wondering why it is losing market share to Open Source... this might be a good place to start.

    Anyway, I found that joeware.net has a executable command line tool that will email enable an AD group - so I will try to work with that.  So I found a way to call a command line instruction from a C# program, I just need to do it remotely - or remotely call the C# program.  Any ideas?

    Thursday, June 25, 2009 1:05 PM