邮件系统

感谢您使用微软产品。  
     
  这个问题好像我们以前讨论过的。-:)  
   
  建议您研究一下CDOEXM组件。同时,Exchange   2000依赖于Windows   2000   AD,   所以也要用到ADSI.  
   
  下面是我以前参于讨论的一个Post,   由于link失效,把内容paste如下:  
   
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////  
  C#中如何实现在Exchange中自动生成一个e-Mail地址和帐号?  
   
  1。   我们可以使用System.DirectoryServices来生成Windows   2000   AD中的新用户。  
   
  2。   请您在要运行该代码的机器上面安装Exchange   Administrative   Tool.   然后我们可以在VS.NET中通过Add   Reference,   把"CDO   for   Exchange   Management(CDOEXM)"引入您的工程。通过Interop,我们可以使用该组件在Exchange上面生成新的mailbox.  
   
  3。   如果您要在ASP.NET中使用,   您需要利用impersonate,把ASPNET账号impersonate到有权限生成mailbox的账号,通常情况下,应该是一个domain   adminstrators组成员。  
   
  下面是一个C#   控制台程序供您参考:  
   
  /////////////////////////////////////////////////////////  
  using   System;  
  using   CDOEXM;  
  using   System.DirectoryServices;  
   
  namespace   MBTest  
  {  
            class   Class1  
            {  
                    [STAThread]  
                    static   void   Main(string[]   args)  
                    {  
                                      //TODO:   Change   these   items   to   values   for   your   domain   or   organization.  
                                      string   defaultNC   =   "DC=yourdomain,DC=com";  
                                      string   alias   =   "jsmith";    
                                      string   fullName   =   "Joseph   Smith";  
                                      string   password   =   "TestMb123.";  
                                      string   domainName   =   "yourdomain.com";  
                                      string   homeMDB   =   "CN=Mailbox   Store   (Your   Server),CN=Your   Storage   Group,"    
                                                          +   "CN=InformationStore,CN=Your   Server,CN=Servers,"  
                                                          +   "CN=Your   Administrative   Group,CN=Administrative   Groups,"  
                                                          +   "CN=Your   Org,CN=Microsoft   Exchange,CN=Services,"  
                                                          +   "CN=Configuration,DC=Yourdomain,DC=Com";  
   
                                      DirectoryEntry   container,   user;  
                                      CDOEXM.IMailboxStore   mailbox;  
   
                                      //This   creates   the   new   user   in   the   "users"   container.  
                                      //Set   the   sAMAccountName   and   the   password  
                                      container   =   new   DirectoryEntry("LDAP://cn=users,"   +   defaultNC);  
                                      user   =   container.Children.Add("cn="   +   fullName,   "user");  
                                      user.Properties["sAMAccountName"].Add(alias);  
                                      user.CommitChanges();  
                                      user.Invoke("SetPassword",   new   object[]{password});  
                                       
                                      //This   enables   the   new   user:  
                                      user.Properties["userAccountControl"].Value   =   0x200;   //ADS_UF_NORMAL_ACCOUNT  
                                      user.CommitChanges();  
   
                                      //Obtain   the   IMailboxStore   interface,   create   the   mailbox,   and   commit   the   changes  
                                      mailbox   =   (IMailboxStore)user.NativeObject;  
                                      mailbox.CreateMailbox(homeMDB);  
                                      user.CommitChanges();  
   
                                      return;  
                            }  
                  }  
        }   /////////////////////////////////////////////////////////////  
   
   
  关于更多的System.DirectoryServices信息,   请您参阅下面的网页:  
   
  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDirectoryServices.asp  
   
  关于更多的CDOEXM信息,请您参阅下面的微软网页:  
   
  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_esdk_reference_cdoexm.asp  
   
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////  
     
  希望对您有所帮助。  
     
  -微软全球技术中心     -zgh  
     
  本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。  
  为了为您创建更好的讨论环境,请参加我们的用户满意度调查(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。

你可能感兴趣的:(邮件)