Visual FoxPro
Visual FoxPro
Add S/MIME Signature using PFX
See more MIME Examples
Add a digital signature to a MIME message using the certificate + private key from a PFX file.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loMime
LOCAL loCert
LOCAL lcPfxFilepath
LOCAL lcPfxPassword
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loMime = CreateObject('Chilkat.Mime')
* Load a PFX file into a certificate object.
loCert = CreateObject('Chilkat.Cert')
lcPfxFilepath = "pfxFiles/something.pfx"
lcPfxPassword = "secret"
lnSuccess = loCert.LoadPfxFile(lcPfxFilepath,lcPfxPassword)
IF (lnSuccess = 0) THEN
? loCert.LastErrorText
RELEASE loMime
RELEASE loCert
CANCEL
ENDIF
lnSuccess = loMime.SetBodyFromPlainText("This is the plain-text MIME body.")
loMime.Charset = "utf-8"
loMime.Encoding = "quoted-printable"
* Sign the MIME (adds a PKCS7 detached signature)
lnSuccess = loMime.AddDetachedSignature(loCert)
IF (lnSuccess = 0) THEN
? loMime.LastErrorText
RELEASE loMime
RELEASE loCert
CANCEL
ENDIF
* Save the S/MIME to a file.
lnSuccess = loMime.SaveMime("/temp/signedMime.txt")
IF (lnSuccess = 0) THEN
? loMime.LastErrorText
RELEASE loMime
RELEASE loCert
CANCEL
ENDIF
? "success!"
RELEASE loMime
RELEASE loCert