Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Save Web Page to MHT String
See more MHT / HTML Email Examples
Downloads a web page into a string variable containing MHT. MHT is a web archive with all images and style sheets embedded. It's a MIME-formatted text document. When saved with the .mht extension, Internet Explorer can open and display the page.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.Mht;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
mht: TMht;
mhtStr: string;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
mht := TMht.Create;
mhtStr := mht.GetMHT('http://www.google.com/');
if (mht.LastMethodSuccess <> True) then
begin
WriteLn(mht.LastErrorText);
end
else
begin
WriteLn(mhtStr);
end;
mht.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.