Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Extract Files from MIME
See more MIME Examples
Extract files from a MIME message.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,
Chilkat.StringTable;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
mime: TMime;
st: TStringTable;
n: Integer;
i: Integer;
begin
success := False;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
mime := TMime.Create;
// Load a MIME document from a file:
// (.mht and .eml files contain MIME).
success := mime.LoadMimeFile('mst.mht');
if (success = False) then
begin
WriteLn(mime.LastErrorText);
Exit;
end;
st := TStringTable.Create;
success := mime.PartsToFiles('/temp/mimeParts',st);
if (success = False) then
begin
WriteLn(mime.LastErrorText);
Exit;
end;
n := st.Count;
// Display the paths of the files created:
i := 0;
while i < n do
begin
WriteLn(st.StringAt(i));
i := i + 1;
end;
mime.Free;
st.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.