Sample code for 30+ languages & platforms
Lazarus Pascal Requires Chilkat v11.0.0+

Read To and Cc from a received message

See more Email Object Examples

Enumerate visible recipients by zero-based index. An address can have an empty display name. A delivered copy usually does not reveal recipients who were blind-copied.

Chilkat Lazarus Pascal Downloads

Lazarus Pascal
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.Email;

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

procedure RunDemo;
var
  success: Boolean;
  email: TEmail;
  i: Integer;

begin
  success := False;

  //  Assumes Chilkat is unlocked. See Global Unlock Sample.

  email := TEmail.Create;
  success := email.LoadEml('message.eml');
  if (success <> True) then
    begin
      WriteLn(email.LastErrorText);
      Exit;
    end;
  i := 0;
  while (i < email.NumTo) do
    begin
      WriteLn('To: ' + email.GetToName(i) + '  ' + email.GetToAddr(i));
      i := i + 1;
    end;

  i := 0;
  while (i < email.NumCC) do
    begin
      WriteLn('Cc: ' + email.GetCcName(i) + '  ' + email.GetCcAddr(i));
      i := i + 1;
    end;



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