(SQL Server) Pack Local HTML File and Referenced Images as MHT Archive
Demonstrates how to pack a local HTML file and referenced files (images, style sheets, etc.) into a .mht web archive.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @mht int
-- Use "Chilkat_9_5_0.Mht" for versions of Chilkat < 10.0.0
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, 'GetAndSaveMHT', @success OUT, 'C:/AAWorkarea/mht_unpack/test.html', 'qa_output/test.mht'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @mht, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mht
RETURN
END
ELSE
BEGIN
PRINT 'MHT Created!'
END
EXEC @hr = sp_OADestroy @mht
END
GO
|