SQL Server
SQL Server
MIME Multipart Boundary and Preamble Properties
See more MIME Examples
Demonstrates the Boundary property, which gets or sets the raw boundary token of a multipart entity (without surrounding quotation marks), and UseMmDescription, which controls whether the conventional preamble text is emitted when serializing a multipart entity.
Background. A multipart boundary separates the constituent parts. Chilkat quotes the token automatically in the header when required. The preamble is ignored by MIME-aware readers and is off by default.
Chilkat SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
DECLARE @mime int
EXEC @hr = sp_OACreate 'Chilkat.Mime', @mime OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Create a multipart/mixed entity.
EXEC sp_OAMethod @mime, 'NewMultipartMixed', @success OUT
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @mime, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mime
RETURN
END
-- Boundary is the raw boundary token, without surrounding quotation marks. Chilkat quotes it
-- automatically in the serialized header when required.
EXEC sp_OASetProperty @mime, 'Boundary', 'example-boundary'
-- UseMmDescription controls whether the conventional preamble text
-- "This is a multi-part message in MIME format." is emitted. The default is 0.
EXEC sp_OASetProperty @mime, 'UseMmDescription', 1
-- Add a simple part so the multipart has content.
DECLARE @part int
EXEC @hr = sp_OACreate 'Chilkat.Mime', @part OUT
EXEC sp_OAMethod @part, 'SetBodyFromPlainText', @success OUT, 'First part.'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @part, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mime
EXEC @hr = sp_OADestroy @part
RETURN
END
EXEC sp_OAMethod @mime, 'AppendPart', @success OUT, @part
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @mime, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mime
EXEC @hr = sp_OADestroy @part
RETURN
END
EXEC sp_OAGetProperty @mime, 'Boundary', @sTmp0 OUT
PRINT 'Boundary = ' + @sTmp0
DECLARE @mimeStr nvarchar(4000)
EXEC sp_OAMethod @mime, 'GetMime', @mimeStr OUT
EXEC sp_OAGetProperty @mime, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @mime, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mime
EXEC @hr = sp_OADestroy @part
RETURN
END
PRINT @mimeStr
EXEC @hr = sp_OADestroy @mime
EXEC @hr = sp_OADestroy @part
END
GO