Save the page for the MHT code

xiaoxiao2021-03-06  23

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: TWebBBBBBBBBROWSER; FileName: TFileName);

VAR

MSG: IMESSAGE;

Conf: iconfiguration;

Stream: _Stream;

URL: WideString;

Begin

IF not assigned (wb.document).

URL: = WB.LocationURL;

Msg: = casseage.create;

CONF: = Coconfiguration.create;

Try

Msg.Configuration: = Conf;

Msg.createmhtmlbody (URL, CDoSuppressall, '', ');

Stream: = msg.getStream;

Street.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 that you probably already have 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 an auto... Generated unit by delphi. To create it, from the main menu Select "import type library", select "c: /windows/system32/cdosys.dll" The Click The "create unit" button.

转载请注明原文地址:https://www.9cbs.com/read-66215.html

New Post(0)