-1

我正在尝试查找是否已回复特定邮件。

我在网上找到了代码,但它使用了 Outlook 2010 中没有的 CDO 库。

是否有等效于以下内容的 VBA:

Sub ShowVerbText()
    Dim objItem As Object
    Dim cdoSession As MAPI.Session
    Dim cdoMessage As MAPI.Message
    Dim cdoField As MAPI.Field
    Dim objFolder As Outlook.MAPIFolder
    Dim strEntryID As String
    Dim strStoreID As String
    Const cdoPR_LAST_VERB_EXECUTED = &H10810003
    Const cdoPR_LAST_VERB_EXECUTION_TIME = &H10820040
    Dim strLastVerb As String
    Dim intLastVerb As Integer
    Dim dteLastVerbTime As Date
    Dim strLastVerbTime As String
    On Error Resume Next

    ' GetCurrentItem function is available at
    ' http://www.outlookcode.com/codedetail.aspx?id=50
    Set objItem = GetCurrentItem()
    If objItem.Class = olMail Then
        If objItem.Sent = True Then
            ' get EntryID and StoreID from item
            Set objFolder = objItem.Parent
            strEntryID = objItem.EntryID
            strStoreID = objFolder.StoreID
            ' initiate CDO session
            Set cdoSession = CreateObject("MAPI.Session")
            cdoSession.Logon "", "", False, False
            ' get same item as CDO Message
            Set cdoMessage = cdoSession.GetMessage(strEntryID, strStoreID)
            Set cdoField = cdoMessage.Fields(cdoPR_LAST_VERB_EXECUTED)
            If Not cdoField Is Nothing Then
                intLastVerb = cdoField.Value
                strLastVerb = LastVerbText(intLastVerb)
                Set cdoField = cdoMessage.Fields(cdoPR_LAST_VERB_EXECUTION_TIME)
                If Not cdoField Is Nothing Then
                    dteLastVerbTime = cdoField.Value
                    strLastVerbTime = FormatDateTime(dteLastVerbTime, vbGeneralDate)
                End If
            Else
                strLastVerb = "No reply or forward"
            End If

            MsgBox strLastVerb & vbCrLf & strLastVerbTime
        End If
    End If

    cdoSession.Logoff
    Set cdoSession = Nothing
    Set cdoMessage = Nothing
    Set cdoField = Nothing
    Set objFolder = Nothing
    Set objItem = Nothing
End Sub

Function LastVerbText(intVerb As Integer)
    ' REFERENCE: http://doc.ddart.net/msdn/header/include/exchform.h.html
    Select Case intVerb
        Case 102
            LastVerbText = "Reply to Sender"
        Case 103
            LastVerbText = "Reply to All"
        Case 104
            LastVerbText = "Forward"
        Case 108
            LastVerbText = "Reply to Forward"
        Case Else
            LastVerbText = "Verb not in list. " & vbCrLf & vbCrLf & _
                "See http://doc.ddart.net/msdn/header/include/exchform.h.html"
    End Select
End Function
4

1 回答 1

0

而不是使用 Message.Fields[],而是使用 MailItem.PropertyAccessor.GetProperty

intLastVerb = objItem.PropertyAccessor.getProperty("http://schemas.microsoft.com/mapi/proptag/0x10810003")

要查看 DALS 属性名称,请使用OutlookSpy查看消息:单击 IMessage,选择有问题的属性,查看 DASL 编辑框。

于 2013-10-15T14:47:30.710 回答