如何通过Outlook自动化获取属于已读回执(ReportItem)的MailItem

时间:2012-11-13 16:40:35

标签: automation outlook vsto outlook-addin mailitem

Outlook将阅读回执存储为ReportItem个对象。

是否可以获得属于给定阅读回执的原始邮件的ID或某些详细信息?我查看了properties of the ReportItem对象,但我迷路了。

由于阅读收据以不同的形式出现,我不想以编程方式处理收据的正文 - 相反,如果可能的话,我希望从Outlook中获取收据。

注意:解决方案应该至少从Outlook 2003工作到新版本。

3 个答案:

答案 0 :(得分:3)

看起来ReportItem与来源MailItem之间的唯一链接是ConversationIndexConversationTopic。这是Outlook用于将已读回执消息与相关来源MailItem链接在一起的内容。您只需要filter by the ConversationTopic然后use the first 44 chars of the ConversationIndex to identify the original source MailItem

示例对话索引

来源索引01CDC1C35624E2A7BD18CF8C439CA73B62A052922657
收据索引01CDC1C35624E2A7BD18CF8C439CA73B62A0529226570000012862

您可以使用Items.Restrict将项目缩减为特定的DASL过滤器

DASL搜索:

[ConversationTopic] = 'read receipt ConversationTopic here'

查找ReportItem的父MailItem

Outlook.MailItem source = FindReadReceiptSourceMessage(ri);
string entryID = source.EntryID;
// ...
public static Outlook.MailItem FindReadReceiptSourceMessage(Outlook.ReportItem readReceipt) 
{
    Outlook.Folder inbox = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) as Outlook.Folder;
    string sourceIndex = readReceipt.ConversationIndex.Substring(0, 44);
    string topicFilter = string.Format("[ConversationTopic] = '{0}'", readReceipt.ConversationTopic);
    Outlook.Items topicItems = inbox.Items.Restrict(topicFilter);
    return topicItems.OfType<Outlook.MailItem>().Where(c=>c.ConversationIndex.Equals(sourceIndex)).FirstOrDefault();
}

答案 1 :(得分:0)

你的意思是:“你只需要通过ConversationTopic过滤,然后使用ConversationIndex的前44个字符来识别原始的源MailItem。”

但我认为我们只过滤了ConversationIndex的前44个字符。因为如果有2封电子邮件具有相同的ConversationTopic,那么我们就不需要使用ConversationTopic进行过滤。

答案 2 :(得分:0)

在项目'myitem'上使用Remdemption库。在我看来比上面更好

    If vs_sender = "" Then 'read receipts
            Set objSMail = CreateObject("Redemption.SafeMailItem")
            objSMail.item = myitem
            vs_sender = objSMail.SenderEmailAddress
            vs_recipient = myitem.Recipients(1).Address
            Set objSMail = Nothing
    End If
相关问题