Here's how to save a Web page as a single file (MHT format) using Delphi code:
Uses cdo_tlb, adodb_tlb;
...
PRocedure wb_saveas_mht (Wb:twebbrowser; Filename:tfilename);
Var
Msg:imessage;
Conf:iconfiguration;
Stream: _stream;
url:widestring;
Begin
If not Assigned (WB. Document) then Exit;
URL: = WB. Locationurl;
MSG: = comessage.create;
Conf: = coconfiguration.create;
Try
Msg.configuration: = Conf;
Msg.createmhtmlbody (URL, Cdosuppressall, ",");
Stream: = Msg.getstream;
Stream.savetofile (FileName, adsavecreateoverwrite);
Finally
MSG: = nil;
Conf: = nil;
Stream: = nil;
End
End (* wb_saveas_mht *)
Sample usage:
First Navigate
WebBrowser1.Navigate (' http://delphi.about.com ');
Then save
WB_SAVEAS_MHT (WebBrowser1, ' c:\WebBrowser1.mht ');
Note 1:the _stream class is defined in Adodb_tlb unit so you probably already has created. The IMessage and IConfiguration interfaces code from Cdosys.dll Library. CDO stands for collaboration Data Objects-object libraries designed to enable SMTP Messaging.
The cdo_tlb is a auto generated unit by Delphi. To create it, from the main menu select "Import Type Library", select "C:\WINDOWS\system32\cdosys.dll" then click the "Cre Ate unit "button.
Data reference: http://www.knowsky.com/336151.html
Save a Web page as a single file (MHT format) using Delphi code