Error HRESULT E_FAIL when creating Exchange mailbox (CDOEXM.IMailboxStore.CreateMailbox)
Posted
by Matt
on Stack Overflow
See other posts from Stack Overflow
or by Matt
Published on 2009-01-16T16:23:22Z
Indexed on
2010/03/14
20:05 UTC
Read the original article
Hit count: 250
I am trying to automate the process of creating an Exchange Mailbox for AD users and am running into an issue. When calling the CreateMailbox method I am receiving the error "Error HRESULT E_FAIL has been returned from a call to a COM component". I have installed and referenced the Exchange Management Tools and am using impersonation for permissions.
Here is the code:
ActiveDs.IADsUser adUser = (ActiveDs.IADsUser)user.NativeObject;
adUser.AccountDisabled = !Active;
user.CommitChanges();
//Set Password
user.Invoke("SetPassword", Password);
user.CommitChanges();
//Create Mailbox
IMailboxStore mailbox;
mailbox = (IMailboxStore)adUser;
mailbox.CreateMailbox("LDAP://CN=StandardUsers,CN=StandardUsers,CN=InformationStore,CN=xxxxx," +
"CN=Servers,CN=First Administrative Group,CN=Administrative Groups," +
"CN=xxxxx Main,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=xxxxx,DC=com");
user.CommitChanges();
© Stack Overflow or respective owner