【问题标题】:Outlook Addin accessing exchange recipient in offline mode?Outlook插件在脱机模式下访问交换收件人?
【发布时间】:2022-04-22 23:29:31
【问题描述】:

我正在使用 VS 2008 和 C# 创建 Outlook 插件。为了发挥作用,此插件使用 Redemption 遍历所有电子邮件并对其进行解析。

我最近遇到了有人在没有网络连接的情况下打开 Outlook 的问题(网络离线、未插电,或者它像笔记本电脑一样是移动设备,而此时恰好没有连接)。似乎是在获取收件人列表。

System.Runtime.InteropServices.COMException (0x80040115):IAddrBook::OpenEntry 中的错误:MAPI_E_NETWORK_ERROR 错误:与 Microsoft Exchange 的连接不可用。您的网络适配器没有默认网关。 组件:Microsoft Exchange 通讯簿 在 Redemption.RDOAddressEntryClass.get_SMTPAddress()

这发生在这段代码中:

    /// <summary>
    /// Retrieves a list of recipient addresses from an RDOMail object
    /// </summary>
    /// <param name="rdoItem">The email to analyze</param>
    /// <returns>A list of e-mail addresses</returns>
    protected List<string> GetRecipients(RDOMail rdoItem)
    {
        RDORecipients recipients = rdoItem.Recipients;
        List<string> recipientList = new List<string>();
        if (recipients != null && recipients.Count > 0)
        {
            for (int i = 1; i <= recipients.Count; i++)
            {
                RDOAddressEntry addressEntry = recipients[i].AddressEntry;
                if (addressEntry != null)
                {
                    string recipient = addressEntry.SMTPAddress;
                    recipient = recipient.Trim();
                    if (recipient != null && recipient != String.Empty)
                    {
                        recipientList.Add(recipient);
                    }

                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(addressEntry);
                    addressEntry = null;
                }
            }
        }

        if (recipients != null)
        {
            System.Runtime.InteropServices.Marshal.FinalReleaseComObject(recipients);
            recipients = null;
        }

        return recipientList;
    }

所以问题是,我如何在不需要对 Exchange 进行身份验证或从 Exchange 解析的情况下获取电子邮件的收件人,并且它会因为没有网络连接而死掉?

编辑:或者 - 有没有办法在 Outlook 中缓存 smtp 电子邮件地址,以便以后脱机时不必解析电子邮件地址?

【问题讨论】:

  • 您是否尝试在缓存模式下使用 Outlook?
  • 我试图不以此作为假设并找到解决方法。

标签: c# exchange-server outlook-addin outlook-redemption


【解决方案1】:

我相信一些商店提供商是底层 PST 商店的包装器。因此,当访问某些属性时,提供者将尝试与远程服务器同步。您应该能够通过从提供者处解开商店来阻止这种情况。

注意:例如,将项目添加到未包装的商店不应将该更改保留到服务器(在 IMAP4 的情况下)。

Redemption website 上阅读有关 UnwrapStore 属性的更多信息

【讨论】:

    【解决方案2】:

    在大多数情况下,PR_SMTP_ADDRESS 属性应该在收件人表中可用(它存储在邮件本身而不是 GAL 中)。您可以使用 RDORecipient.Fields[] 访问该属性 - 没有理由使用 RDORecipient.AddressEntry(这会导致 Redemption 调用 IAddrbook::OpenEntry,并且在离线模式下调用可能会失败)。

    查看带有OutlookSpy(我是其作者)的收件人表 - 单击 IMessage,转到 GetRecipientTable 选项卡以确保存在 PR_SMTP_ADDRESS 属性。

    【讨论】:

    • 我可以确认这不适用于 Exchange。
    • 您使用的是哪个版本的 Outlook 和 Exchange?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-09
    • 1970-01-01
    • 2021-01-02
    • 2016-02-19
    • 2023-03-10
    相关资源
    最近更新 更多