SQL Server
SQL Server
Serialize MIME to a StringBuilder
See more MIME Examples
Demonstrates the Chilkat Mime.GetMimeSb method, which serializes the complete MIME entity and appends it to a StringBuilder. The only argument is the StringBuilder; existing content is preserved.
Background: Serializing into a
StringBuilder avoids creating a new string and is convenient when you are accumulating output or building a larger document. Because it appends, you can assemble several pieces in one buffer. As with GetMime, use the BinData form for content with arbitrary binary bytes.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- Demonstrates the Mime.GetMimeSb method, which serializes the complete MIME entity and appends
-- it to a StringBuilder. The only argument is the StringBuilder.
DECLARE @mime int
EXEC @hr = sp_OACreate 'Chilkat.Mime', @mime OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OAMethod @mime, 'SetBodyFromPlainText', @success OUT, 'Hello, this is the message body.'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @mime, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mime
RETURN
END
-- Append the serialized MIME to a StringBuilder. Existing content is preserved.
DECLARE @sb int
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sb OUT
EXEC sp_OAMethod @mime, 'GetMimeSb', @success OUT, @sb
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @mime, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mime
EXEC @hr = sp_OADestroy @sb
RETURN
END
EXEC sp_OAMethod @sb, 'GetAsString', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mime
EXEC @hr = sp_OADestroy @sb
END
GO