Sample code for 30+ languages & platforms
Classic ASP

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 Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

set mime = Server.CreateObject("Chilkat.Mime")
success = mime.SetBodyFromPlainText("This message will be encrypted.")
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( mime.LastErrorText) & "</pre>"
    Response.End
End If

'  Add a recipient certificate.
set cert = Server.CreateObject("Chilkat.Cert")
success = cert.LoadFromFile("qa_data/recipient.cer")
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( cert.LastErrorText) & "</pre>"
    Response.End
End If

success = mime.AddEncryptCert(cert)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( mime.LastErrorText) & "</pre>"
    Response.End
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 

Response.Write "<pre>" & Server.HTMLEncode( "Recipient certificate list cleared.") & "</pre>"

%>
</body>
</html>