Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loMime
LOCAL loCert

lnSuccess = 0

loMime = CreateObject('Chilkat.Mime')
lnSuccess = loMime.SetBodyFromPlainText("This message will be encrypted.")
IF (lnSuccess = 0) THEN
    ? loMime.LastErrorText
    RELEASE loMime
    CANCEL
ENDIF

*  Add a recipient certificate.
loCert = CreateObject('Chilkat.Cert')
lnSuccess = loCert.LoadFromFile("qa_data/recipient.cer")
IF (lnSuccess = 0) THEN
    ? loCert.LastErrorText
    RELEASE loMime
    RELEASE loCert
    CANCEL
ENDIF

lnSuccess = loMime.AddEncryptCert(loCert)
IF (lnSuccess = 0) THEN
    ? loMime.LastErrorText
    RELEASE loMime
    RELEASE loCert
    CANCEL
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