【问题标题】:MAPI_E_FAILONEPROVIDER from Redemption来自兑换的 MAPI_E_FAILONEPROVIDER
【发布时间】:2011-03-10 17:36:12
【问题描述】:

我正在尝试通过用户兑换来更新用户的 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

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

【问题讨论】:

    标签: c# outlook exchange-server outlook-redemption cdo.message


    【解决方案1】:

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

    【讨论】:

    • 感谢您的帮助!赎回是一个很好的工具。
    【解决方案2】:

    这是 Dmitry 答案的代码。 它还使用了来自Milan's blog 的函数。

            public OutlookFolders(string exchangeUser, string mailServer)
            {
                var session = new RDOSessionClass();
                var userFullName = GetFullName("DOMAIN-NT\\" + Environment.UserName);
                session.LogonExchangeMailbox(userFullName, mailServer);
                session.Stores.FindExchangePublicFoldersStore();
                var store = session.GetSharedMailbox(exchangeUser);
                rootFolder = store.GetDefaultFolder((rdoDefaultFolders)OlDefaultFolders.olFolderContacts);
            }
    
            public static string GetFullName(string strLogin)
            {
                string str = "";
                string strDomain;
                string strName;
    
                // Parse the string to check if domain name is present.
                int idx = strLogin.IndexOf('\\');
                if (idx == -1)
                {
                    idx = strLogin.IndexOf('@');
                }
    
                if (idx != -1)
                {
                    strDomain = strLogin.Substring(0, idx);
                    strName = strLogin.Substring(idx + 1);
                }
                else
                {
                    strDomain = Environment.MachineName;
                    strName = strLogin;
                }
    
                DirectoryEntry obDirEntry = null;
                try
                {
                    obDirEntry = new DirectoryEntry("WinNT://" + strDomain + "/" + strName);
                    PropertyCollection coll = obDirEntry.Properties;
                    object obVal = coll["FullName"].Value;
                    str = obVal.ToString();
                }
                catch (System.Exception ex)
                {
                    str = ex.Message;
                }
                return str;
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-30
      • 2021-10-01
      • 2016-06-18
      相关资源
      最近更新 更多