Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Check Whether an Email Is a multipart/report
See more Email Object Examples
Demonstrates the Chilkat Email.IsMultipartReport method, which returns true when the top-level message structure is a multipart/report (such as a bounce/DSN or a read receipt/MDN). This example loads an email and reports whether it is a multipart/report.
Background: Automated mail — delivery failures and read receipts — arrives wrapped in the
multipart/report structure, which carries machine-readable report parts. Detecting it with IsMultipartReport is the first step in a bounce-handling pipeline: once you know a message is a report, you can pull its parts with GetReport or read delivery fields with GetDeliveryStatusInfo to act on failures automatically.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
success: Boolean;
email: TEmail;
begin
success := False;
// Demonstrates the IsMultipartReport method, which returns true if the top-level message
// structure is a multipart/report (such as a bounce / DSN or a read receipt / MDN).
email := TEmail.Create;
success := email.LoadEml('qa_data/eml/dsn_bounce.eml');
if (success = False) then
begin
WriteLn(email.LastErrorText);
Exit;
end;
if (email.IsMultipartReport() = True) then
begin
WriteLn('This email is a multipart/report (e.g. a bounce or read receipt).');
end
else
begin
WriteLn('This email is not a multipart/report.');
end;
// Note: The path "qa_data/..." is a relative local filesystem path,
// relative to the current working directory of the running application.
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.