Save the code on the page as MHT

Source: Internet
Author: User

Here's how to save a web page as a single file (MHT format) using Delphi code:

 
 
UsesCdo_tlb, adodb_tlb ;...ProcedureWb_saveas_mht (WB: twebbrowser; filename: tfilename );VaRMSG: iMessage; Conf: iconfiguration; stream: _ stream; Url: widestring;BeginIf NotAssigned (WB. Document)Then Exit; Url: = WB. locationurl; MSG: = comessage. Create; Conf: = coconfiguration. Create;TryMSG. Configuration: = conf; msg. createmhtmlbody (URL, cdosuppressall, '',''); stream: = msg. getstream; stream. savetofile (filename, adsavecreateoverwrite );FinallyMSG: =Nil; Conf: =Nil; Stream: =Nil;End;End;(* Wb_saveas_mht *)

Sample usage:

 
// First navigateWebbrowser1.navigate ('HTTP: // delphi.about.com ');// Then saveWb_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 "then click the" Create unit "button.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.