SQL Server Stored Procedure Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

SQL Server
Stored Procedure Examples

Quick Start
Encryption
File Access
IMAP
POP3
SMTP
Email Object
FTP
HTML-to-XML
HTTP
MHT
MIME
RSA Encryption
Socket
Spider
String
Tar
Upload
XML
XMP
Zip

Byte Array
RSS
Atom
Self-Extractor

Download Web Page to MHT with w/ Disk Cache

Downloads a web page into a .mht web archive. Embedded images and style sheets are loaded and/or saved to a disk cache. Note: The disk caching functionality is available in official new versions released after 30-October-2007, or in the current pre-release downloads.

Download Chilkat MHT ActiveX

CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    DECLARE @mht int
    EXEC @hr = sp_OACreate 'Chilkat.Mht', @mht OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    EXEC sp_OAMethod @mht, 'UnlockComponent', @success OUT, '30-day trial'
    IF @success <> 1
      BEGIN
        PRINT 'Mht component unlock failed'
        RETURN
      END

    --  Use a single directory to hold cached files.
    EXEC sp_OASetProperty @mht, 'NumCacheLevels', 0
    EXEC sp_OAMethod @mht, 'AddCacheRoot', NULL, 'c:/temp/mhtCache/'

    --  Tell the MHT component to save files to cache,
    --  and to retrieve from cache if possible:
    EXEC sp_OASetProperty @mht, 'FetchFromCache', 1
    EXEC sp_OASetProperty @mht, 'UpdateCache', 1

    --  The 1st time this is run, the parts (image files,
    --  style sheets, etc.) will be saved to the disk cache.
    --  The 2nd time this is run, the parts will load from cache.
    --  Note: The main content (i.e. the HTML page)
    --  is not saved to cache, nor is it retrieved from cache.
    --  It is only the sub-parts (embedded images, style sheets)
    --  that are saved to and loaded from cache.
    EXEC sp_OAMethod @mht, 'GetAndSaveMHT', @success OUT, 'http://www.intel.com/', 'intel.mht'

    EXEC sp_OAGetProperty @mht, 'LastErrorText', @sTmp0 OUT

    PRINT @sTmp0

    IF @success <> 1
      BEGIN
        PRINT 'MHT Failed!'
      END
    ELSE
      BEGIN
        PRINT 'MHT Created!'
      END
END
GO

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.