Title: save HTML pages as MHTML (HTML Archiv Format)?
function SaveToMHT(const AUrl, AFileName: string;
AShowErrorMessage: Boolean = False): Boolean;
var
oMSG, oConfig: OleVariant;
sFileName: string;
Retvar: Boolean;
begin
sFileName := ChangeFileExt(AFileName, '.mht');
DeleteFile(PAnsiChar(sFileName));
try
oConfig := CreateOleObject('CDO.Configuration');
oMSG := CreateOleObject('CDO.Message');
oMSG.Configuration := oConfig;
oMSG.CreateMHTMLBody(AUrl);
oMSG.GetStream.SaveToFile(sFileName);
Retvar := True;
except
on E: Exception do
begin
if AShowErrorMessage then MessageDlg(E.Message, mtError, [mbOK], 0);
Retvar := False;
end;
end;
oMSG := VarNull;
oConfig := VarNull;
Result := Retvar;
end;