SQL Server
SQL Server
Load MIME from a String
See more MIME Examples
Demonstrates the Chilkat Mime.LoadMime method, which parses complete MIME text and replaces the current object's headers, body, and multipart tree. The only argument is the MIME string.
Background: MIME is the structure behind email messages and many other content containers — a set of headers, a blank line, then a body that may itself be a tree of nested parts. Loading parses that text into an object you can then inspect and modify part by part. A successful load fully replaces whatever the object held before, and Chilkat is tolerant of common real-world formatting quirks. When the content may contain raw 8-bit or NUL bytes, prefer
LoadMimeBd so nothing is forced through a text string.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 @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- Demonstrates the Mime.LoadMime method, which parses complete MIME text and replaces the current
-- object's headers, body, and multipart tree. The only argument is the MIME string.
DECLARE @mime int
EXEC @hr = sp_OACreate 'Chilkat.Mime', @mime OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- The complete MIME text (headers, a blank line, then the body).
DECLARE @mimeText nvarchar(4000)
SELECT @mimeText = 'Content-Type: text/plain' + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10) + 'This is the body.' + CHAR(13) + CHAR(10)
EXEC sp_OAMethod @mime, 'LoadMime', @success OUT, @mimeText
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @mime, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mime
RETURN
END
EXEC sp_OAGetProperty @mime, 'ContentType', @sTmp0 OUT
PRINT 'Content-Type: ' + @sTmp0
EXEC @hr = sp_OADestroy @mime
END
GO