Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Get the Entire Serialized MIME Body
See more MIME Examples
Demonstrates the Chilkat Mime.GetEntireBody method, which returns the complete serialized body of the current entity. It takes no arguments. For multipart MIME this includes the boundary delimiters and each child part's headers and body.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: This returns everything below the entity's own headers — for a simple part, just the body; for a multipart, the whole nested structure with its boundaries and child headers. It pairs with
GetEntireHead, which returns the header section, so together they let you inspect or reconstruct a message's two halves separately.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.Mime;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
mime: TMime;
entireBody: string;
begin
success := False;
mime := TMime.Create;
success := mime.LoadMimeFile('qa_data/message.eml');
if (success = False) then
begin
WriteLn(mime.LastErrorText);
Exit;
end;
// Return the complete serialized body of the current entity. For multipart MIME, this includes
// the boundary delimiters and each child part's headers and body, but not the entity's own top
// headers.
entireBody := mime.GetEntireBody();
if (mime.LastMethodSuccess = False) then
begin
WriteLn(mime.LastErrorText);
Exit;
end;
WriteLn(entireBody);
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.