Skip to main content
 首页 » 编程设计

c#之来自赎回的 MAPI_E_FAILONEPROVIDER

2024年02月03日35lhb25

我正在尝试使用 Redemption 更新用户的 Outlook 联系人。我影响的用户在 exchangeUser 中传递,称他为“目标用户”。 当我以自己的身份登录运行时,此代码有效:

public OutlookFolders(string outlookRootFolder, string exchangeUser, string mailServer) 
{ 
    var session = new RDOSessionClass(); 
    session.LogonExchangeMailbox(exchangeUser, mailServer); 
    session.Stores.FindExchangePublicFoldersStore(); 
    var store = session.GetSharedMailbox(exchangeUser); 
    //... 
} 

我尝试以第三个用户“测试用户”身份登录,该用户不是我,也不是“目标用户”。当我的程序到达 FindExchangePublicFoldersStore 时,它​​会在运行时弹出密码提示,如果我不填写我的凭据,它将失败并显示错误:

System.Runtime.InteropServices.COMException (0x8004011D): Error in  
    IMAPISession.OpenMsgStore(pbExchangeProviderPrimaryUserGuid): 
    MAPI_E_FAILONEPROVIDER 
ulVersion: 0 
Error: Microsoft Exchange is not available.  Either there are network 
    problems or the Exchange computer is down for maintenance. 
Component: Microsoft Exchange Information Store 
ulLowLevelError: 2147746069 
ulContext: 1318 

我尝试授予“测试用户”所有者对“目标用户”的邮箱和联系人文件夹的权限。似乎没有什么区别。需要设置哪些其他权限才能使其正常工作?

请您参考如下方法:

经验法则是以可以访问相关邮箱的用户身份运行您的代码,为当前用户调用 LogonExchangeMailbox,然后使用 GetSharedMailbox 打开其他用户的邮箱。