(SQL Server) Add Content-Length Header to a MIME Message
The AddContentLength method automatically computes the length of the MIME content and adds a Content-Length header with the correct number of bytes.
-- 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 @mime int
-- Use "Chilkat_9_5_0.Mime" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Mime', @mime OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Set the MIME body:
EXEC sp_OAMethod @mime, 'SetBody', NULL, 'This is a test'
-- The complete size (in bytes) of the contents is computed,
-- even if the MIME is multipart, and the Content-Length header
-- is added.
EXEC sp_OAMethod @mime, 'AddContentLength', NULL
-- Display the MIME:
EXEC sp_OAMethod @mime, 'GetMime', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mime
END
GO
|