Sample code for 30+ languages & platforms
Lianja

Clear the S/MIME Recipient Certificate List

See more MIME Examples

Demonstrates ClearEncryptCerts, which empties the recipient-certificate list previously populated by AddEncryptCert. This is useful to start over with a different set of recipients before calling EncryptN.

Background. The recipient list is internal state that accumulates across AddEncryptCert calls. ClearEncryptCerts resets it so a subsequent EncryptN encrypts only for the certificates added afterward.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

loMime = createobject("CkMime")
llSuccess = loMime.SetBodyFromPlainText("This message will be encrypted.")
if (llSuccess = .F.) then
    ? loMime.LastErrorText
    release loMime
    return
endif

//  Add a recipient certificate.
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

//  ClearEncryptCerts empties the recipient-certificate list, for example to start over with a
//  different set of recipients before calling EncryptN.  It is a void method.
loMime.ClearEncryptCerts()

? "Recipient certificate list cleared."


release loMime
release loCert