【问题标题】:Office.Interop how to find email using PR_SEARCH_KEY in sent FolderOffice.Interop 如何在已发送文件夹中使用 PR_SEARCH_KEY 查找电子邮件
【发布时间】:2018-02-12 01:36:09
【问题描述】:

我正在为我的软件使用 Outlook 对象模型(互操作)。

在我发送电子邮件之前,我会获取并保留我们创建的电子邮件的 PR_SEARCH_KEY。

如果我想使用 PR_SEARCH_KEY 在已发送文件夹中查找电子邮件,如何在 c# 中使用 Office.Interop(不是 EWS 或不兑换)来做到这一点?

我试图从 SentFolder.Items.Find(filter) 中找到它。但它不起作用,因为 PR_SEARCH_KEY 是二进制的。

谢谢!

        public Outlook.MailItem FindEmailFromSentFolder(string emailId)
    {
        try
        {
            if (_sentFolderItems == null)
                return null;

            // find the sent mail from sent folder based on PR_Serach_Key
            var filter = string.Format("@SQL=\"http://schemas.microsoft.com/mapi/proptag/0x300B0102\" = '{0}'",
                                   emailId);

            var item = _sentFolderItems.Find(filter);

            if (item != null && item is Outlook.MailItem)
                return item as Outlook.MailItem;
        }
        catch (Exception ex)
        {
            return null;
        }
        return null;
    }

【问题讨论】:

    标签: outlook interop office-interop


    【解决方案1】:

    您已经注意到,OOM 不允许您搜索任何二进制属性 - 您需要扩展 MAPI(C++ 或 Delphi)或 Redemption(任何语言)。

    最好的办法是在外发邮件上设置一些字符串属性,然后在“已发送邮件”文件夹中查找它。

    【讨论】:

      猜你喜欢
      • 2011-03-13
      • 2014-11-05
      • 2016-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-03
      • 1970-01-01
      相关资源
      最近更新 更多