Visual Basic 6.0 Requires Chilkat v11.0.0+
Visual Basic 6.0
Decrypt an S/MIME email and verify its signature
See more Email Object Examples
Register the recipient’s PFX before opening signed-encrypted.eml. This workflow expects both encryption and a signature, so it checks both layers before reading the message. Cryptographic signature validity is one input to a signer-trust decision.
Chilkat Visual Basic 6.0 Downloads
Dim success As Long
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim email As New ChilkatEmail
success = email.AddPfxSourceFile("recipient.pfx","RECIPIENT_PASSWORD")
If (success <> 1) Then
Debug.Print email.LastErrorText
Exit Sub
End If
success = email.LoadEml("signed-encrypted.eml")
If (success <> 1) Then
Debug.Print email.LastErrorText
Exit Sub
End If
If ((email.ReceivedEncrypted <> 1) Or (email.Decrypted <> 1)) Then
Debug.Print "Expected a successfully decrypted S/MIME envelope."
Exit Sub
End If
If ((email.ReceivedSigned <> 1) Or (email.SignaturesValid <> 1)) Then
Debug.Print "Expected a valid signature inside the envelope."
Exit Sub
End If
' This message has one signer. Examine its certificate after verification.
Dim signer As New ChilkatCert
success = email.LastSignerCert(0,signer)
If (success <> 1) Then
Debug.Print email.LastErrorText
Exit Sub
End If
Debug.Print "Signer certificate: " & signer.SubjectDN
Debug.Print "Recovered subject: " & email.Subject
Debug.Print "Recovered attachments: " & email.NumAttachments