Lianja
Lianja
Add a Recipient Certificate for S/MIME Encryption
See more MIME Examples
Demonstrates AddEncryptCert, which adds one recipient certificate to the list used by EncryptN. Call it once for each intended recipient, then call EncryptN to encrypt for all of them.
The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background. AddEncryptCert builds up the recipient list used by EncryptN. Only the public key of each certificate is required for encryption.
Chilkat Lianja Downloads
llSuccess = .F.
loMime = createobject("CkMime")
llSuccess = loMime.SetBodyFromPlainText("This message will be encrypted.")
if (llSuccess = .F.) then
? loMime.LastErrorText
release loMime
return
endif
// AddEncryptCert adds one recipient certificate to the list used by EncryptN. Call it once per
// recipient.
loCert = createobject("CkCert")
llSuccess = loCert.LoadFromFile("qa_data/recipient.cer")
if (llSuccess = .F.) then
? loCert.LastErrorText
release loMime
release loCert
return
endif
llSuccess = loMime.AddEncryptCert(loCert)
if (llSuccess = .F.) then
? loMime.LastErrorText
release loMime
release loCert
return
endif
// EncryptN then encrypts for all certificates added.
llSuccess = loMime.EncryptN()
if (llSuccess = .F.) then
? loMime.LastErrorText
release loMime
release loCert
return
endif
? "Encrypted for the added recipient(s)."
release loMime
release loCert