Sample code for 30+ languages & platforms
Xojo Plugin

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 Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

Dim mime As New Chilkat.Mime
success = mime.SetBodyFromPlainText("This message will be encrypted.")
If (success = False) Then
    System.DebugLog(mime.LastErrorText)
    Return
End If

//  Add a recipient certificate.
Dim cert As New Chilkat.Cert
success = cert.LoadFromFile("qa_data/recipient.cer")
If (success = False) Then
    System.DebugLog(cert.LastErrorText)
    Return
End If

success = mime.AddEncryptCert(cert)
If (success = False) Then
    System.DebugLog(mime.LastErrorText)
    Return
End If

//  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.
mime.ClearEncryptCerts 

System.DebugLog("Recipient certificate list cleared.")