SaveToMHT Function

Unit
Unit5

Declaration
Function SaveToMHT(const AUrl, AFileName: string; AShowErrorMessage: Boolean = False): Boolean;

Implementation

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;


HTML generated by Time2HELP
http://www.time2help.com