-->

How to save digital signature of received mail

2019-07-22 01:31发布

问题:

I am trying to save the digital signature of the currently opened mail item.

Now I realize that Outlook prevents access to encrypt/sign a new email programmatically. Here I am focused on messages which have been received.

So far, I am just able to use the MessageClass property to detect a signed email.

Function GetCurrentItem() As Object
    Dim objApp As Outlook.Application

    Set objApp = CreateObject("Outlook.Application")
    On Error Resume Next
    Select Case TypeName(objApp.ActiveWindow)
        Case "Explorer"
            Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
        Case "Inspector"
            Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
        Case Else
            ' anything else will result in an error, which is
            ' why we have the error handler above
    End Select

    Set objApp = Nothing
End Function

Sub DoExport()
    Set CurrentItem = GetCurrentItem()
    If CurrentItem.MessageClass = "IPM.Note.SMIME.MultipartSigned" Then
        MsgBox CurrentItem.MessageClass 
    End If
End Sub

回答1:

Messageclass always seems to be "IPM.Note" even on encrypted and signed mail.
I use this code to read who signed the mail.
Set PropertyAccessor = mailitem.PropertyAccessor
If PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/id/{00020328-0000-0000-C000-000000000046}/9104001f") <> "" Then
END
End If