save web as mht format file
Posted: Fri May 07, 2021 2:58 am
IS this the only way?
1.save html first(sometimes picture only appear after browsing )
2.change html to mht.
ref:http://mrxray.on.coocan.jp/Delphi/plSamples/764_SaveWebPage_MHT.htm
first: import component new lib C:\Windows\System32\cdosys.dll
uses CDO_TLB, ADODB_TLB, ComObj
Is there another easy way to do this?
1.save html first(sometimes picture only appear after browsing )
2.change html to mht.
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
Lobjimsg : OleVariant;
Lobjiconf : OleVariant;
LobjStream : OleVariant;
begin
Lobjimsg := CreateOleObject('CDO.Message');
Lobjiconf := CreateOleObject('CDO.Configuration');
LobjStream := CreateOleObject('ADODB.Stream');
try
LObjimsg.Configuration := Lobjiconf; //
Lobjimsg.CreateMHTMLBody('C:\temp\1.html', 0, '', ''); //0: cdoSuppressNone do not use cdoSuppressAll pictures will not be included.
LobjStream := Lobjimsg.GetStream;
LobjStream.SaveToFile('C:\temp\fileName.mht', 2);
finally
Lobjimsg := Unassigned;
Lobjiconf := Unassigned;
LobjStream := Unassigned;
end;
end;
first: import component new lib C:\Windows\System32\cdosys.dll
uses CDO_TLB, ADODB_TLB, ComObj
Is there another easy way to do this?