在VSTO Application.ItemSend子句中,ConversationID是Nothing。

时间:2018-11-22 14:44:14

标签: vb.net outlook vsto

我正在尝试创建一个性能跟踪应用程序-在基本级别上,它将确定我回复电子邮件的速度。

我想我可能使用了错误的“已发送邮件”触发事件,因为下面的子nothing中的某些回复的会话ID为Application_ItemSend

Public Class ThisAddIn
    Public Shared ConversationThreads As Dictionary(Of String, Date)

    Private Sub Application_NewMailEx(EntryIDCollection As String) Handles Application.NewMailEx
        For Each itemID In Split(EntryIDCollection, ",")
            Dim item = Application.Session.GetItemFromID(itemID)
            If TypeName(item) = "MailItem" Then
                'is it a Tracked Email
                Dim msg As Outlook.MailItem
                msg = item
                ConversationThreads.Add(msg.ConversationID, Now())
            End If
        Next

    End Sub

    Private Sub Application_ItemSend(Item As Object, ByRef Cancel As Boolean) Handles Application.ItemSend
        If TypeName(Item) = "MailItem" Then
            'is it a Tracked Email
            Dim msg As Outlook.MailItem
            msg = Item
            For Each tRecipient As Outlook.Recipient In msg.Recipients
                If Not msg.ConversationID Is Nothing AndAlso
                    ConversationThreads.ContainsKey(msg.ConversationID) Then
                      Call OpenCloseThread(msg.ConversationID)
                End If


            Next
        End If

    End Sub

end class

我应该为此子对象使用其他触发器吗?

1 个答案:

答案 0 :(得分:0)

在读取msg.Save()属性之前,请致电ConversationID