下面是我原先用的调用CDOEXM中IMailboxStore接口给用户创建Mailbox的代码: DirectoryEntry deUser; // deUser为域中的用户String sHomeMDB; // sHomeMDB为域中Exchange Mailbox Store的路径 CDOEXM.IMailboxStore mailboxStore = (IMailboxStore) deUser.NativeObject;mailboxStore.CreateMailbox(sHomeMDB);deUser.Update(); 运行到CreateMailbox()这个方法时,Exchange返回来一个“致命性故障”,上面的代码实在是标准得不能再标准的代码,Microsoft在KB中提供的代码示例都是这么几句,郁闷…难道是把DirectoryEntry对象的NativeObject本地对象映射转换成IMailboxStore有问题? 于是,再隔上一层,先转成ADSI中的IADsUser: ActiveDs.IADsUser adsUser = (IADsUser) deUser.NativeObject;CDOEXM.IMailboxStore mailboxStore = (IMailboxStore) adsUser;mailboxStore.CreateMailbox(sHomeMDB);adsUser.SetInfo(); 还是“致命性故障”…于是,Google…终于检索到一个网页,那可怜的哥们和偶一样,也是“Catastrophic failure”,但是好像他比偶聪明那么一点点,他用VB.NET把代码写了一遍,就发现正常了… 就像这样: Dim oMailboxStore As CDOEXM.IMailboxStoreDim oADsUser As ActiveDs.IADsUser oADsUser = GetObject(adsuserPath) ‘ 这里的adsuserPath就是用户的LDAP路径oMailboxStore = oADsUser oMailboxStore.CreateMailbox(homeMdb)oADsUser.SetInfo() 偶再把这段代码在VB.NET里面生成了一个类库,然后在C#中引用、调用,It also works! 但是实在不爽啊…于是盯上了VB.NET中的GetObject()这个函数,暗自想,如果偶在C#里面也调用这个函数… 于是: IADsUser adsUser = (IADsUser) Microsoft.VisualBasic.Interaction.GetObject(deUser.Path, null);IMailboxStore mailboxStore [...]