Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Clear the Bcc Recipients of an Email
See more Email Object Examples
Demonstrates the Chilkat Email.ClearBcc method, which clears the list of blind carbon-copy (Bcc) recipients. It changes only the current in-memory email object and does not affect messages already sent. This example adds two Bcc recipients, clears them, and prints the count before and after.
Background: Reusing one
Email object as a template for several messages is common — you set the subject and body once and vary the recipients. Clearing methods like ClearBcc, ClearCC, and ClearTo let you reset one recipient list between sends without rebuilding the whole message, so a stray Bcc from a previous send does not leak into the next.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;
begin
// Demonstrates the ClearBcc method, which clears the list of blind carbon-copy (Bcc)
// recipients. This changes only the current email object.
email := TEmail.Create;
email.AddBcc('Joe','joe@example.com');
email.AddBcc('Jane','jane@example.com');
WriteLn('NumBcc before clear = ' + email.NumBcc);
// Remove all Bcc recipients.
email.ClearBcc();
WriteLn('NumBcc after clear = ' + email.NumBcc);
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.