Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
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 Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Cert,
Chilkat.Mime;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
mime: TMime;
cert: TCert;
begin
success := False;
mime := TMime.Create;
success := mime.SetBodyFromPlainText('This message will be encrypted.');
if (success = False) then
begin
WriteLn(mime.LastErrorText);
Exit;
end;
// Add a recipient certificate.
cert := TCert.Create;
success := cert.LoadFromFile('qa_data/recipient.cer');
if (success = False) then
begin
WriteLn(cert.LastErrorText);
Exit;
end;
success := mime.AddEncryptCert(cert);
if (success = False) then
begin
WriteLn(mime.LastErrorText);
Exit;
end;
// 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();
WriteLn('Recipient certificate list cleared.');
mime.Free;
cert.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.