Sample code for 30+ languages & platforms
Tcl

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 Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set mime [new_CkMime]

set success [CkMime_SetBodyFromPlainText $mime "This message will be encrypted."]
if {$success == 0} then {
    puts [CkMime_lastErrorText $mime]
    delete_CkMime $mime
    exit
}

#  Add a recipient certificate.
set cert [new_CkCert]

set success [CkCert_LoadFromFile $cert "qa_data/recipient.cer"]
if {$success == 0} then {
    puts [CkCert_lastErrorText $cert]
    delete_CkMime $mime
    delete_CkCert $cert
    exit
}

set success [CkMime_AddEncryptCert $mime $cert]
if {$success == 0} then {
    puts [CkMime_lastErrorText $mime]
    delete_CkMime $mime
    delete_CkCert $cert
    exit
}

#  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.
CkMime_ClearEncryptCerts $mime

puts "Recipient certificate list cleared."

delete_CkMime $mime
delete_CkCert $cert