Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Get a Cc Recipient's Name Only
See more Email Object Examples
Demonstrates the Chilkat Email.GetCcName method, which returns only the friendly-name part (not the address) of the Nth carbon-copy recipient. The index is zero-based. This example adds two Cc recipients and prints each one's display name.
Background: A recipient combines a display name with an address, such as
Jane Doe <jane@example.com>. GetCcName returns just the Jane Doe portion, which is handy for showing a friendly label in a UI. The name is optional free-form text, so it may be empty — when it is, fall back to the address from GetCcAddr.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.Email;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
email: TEmail;
n: Integer;
i: Integer;
begin
// Demonstrates the GetCcName method, which returns only the friendly-name part (not the
// address) of the Nth carbon-copy recipient. The index is zero-based.
email := TEmail.Create;
email.Subject := 'GetCcName example';
email.AddCC('Joe Smith','joe@example.com');
email.AddCC('Jane Doe','jane@example.com');
n := email.NumCC;
for i := 0 to n - 1 do
begin
WriteLn('Cc ' + i + ' name: ' + email.GetCcName(i));
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.