Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

MIME Advanced CMS and Compatibility Option Properties

See more MIME Examples

Demonstrates advanced option properties: CmsOptions (a JSON string of advanced CMS/PKCS #7 signing and validation options), UnwrapExtras (whether UnwrapSecurity adds informative header fields describing removed security layers), and UncommonOptions (an option string for uncommon compatibility requirements).

Background. These properties adjust behavior only in specialized situations. Their defaults (empty CmsOptions, UnwrapExtras enabled, empty UncommonOptions) are correct for normal use; UncommonOptions in particular should be set only when directed by support.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
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.Mime;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  success: Boolean;
  mime: TMime;

begin
  success := False;

  mime := TMime.Create;
  success := mime.SetBodyFromPlainText('Message body.');
  if (success = False) then
    begin
      WriteLn(mime.LastErrorText);
      Exit;
    end;

  //  CmsOptions is a JSON string of advanced CMS/PKCS #7 signing and validation options.  The default
  //  is an empty string, which selects normal behavior.  An empty JSON object {} is also valid.
  mime.CmsOptions := '{}';

  //  UnwrapExtras controls whether UnwrapSecurity adds informative header fields describing the
  //  security layers it removed.  The default is True.
  mime.UnwrapExtras := True;

  //  UncommonOptions is a semicolon-delimited option string for uncommon compatibility requirements.
  //  Normal applications should leave it empty, and it should only be used when directed by support.
  mime.UncommonOptions := '';

  WriteLn('CmsOptions = ' + mime.CmsOptions);
  WriteLn('Advanced options configured.');


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