Visual FoxPro Requires Chilkat v11.0.0+
Visual FoxPro
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 FoxPro Downloads
LOCAL lnSuccess
LOCAL loEmail
LOCAL loSigner
lnSuccess = 0
* Assumes Chilkat is unlocked. See Global Unlock Sample.
loEmail = CreateObject('Chilkat.Email')
lnSuccess = loEmail.AddPfxSourceFile("recipient.pfx","RECIPIENT_PASSWORD")
IF (lnSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
lnSuccess = loEmail.LoadEml("signed-encrypted.eml")
IF (lnSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
IF ((loEmail.ReceivedEncrypted <> 1) OR (loEmail.Decrypted <> 1)) THEN
? "Expected a successfully decrypted S/MIME envelope."
RELEASE loEmail
CANCEL
ENDIF
IF ((loEmail.ReceivedSigned <> 1) OR (loEmail.SignaturesValid <> 1)) THEN
? "Expected a valid signature inside the envelope."
RELEASE loEmail
CANCEL
ENDIF
* This message has one signer. Examine its certificate after verification.
loSigner = CreateObject('Chilkat.Cert')
lnSuccess = loEmail.LastSignerCert(0,loSigner)
IF (lnSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
RELEASE loSigner
CANCEL
ENDIF
? "Signer certificate: " + loSigner.SubjectDN
? "Recovered subject: " + loEmail.Subject
? "Recovered attachments: " + STR(loEmail.NumAttachments)
RELEASE loEmail
RELEASE loSigner