SQL Server
SQL Server
Load MIME from XML
See more MIME Examples
Demonstrates the Chilkat Mime.LoadXml method, which reconstructs a MIME tree from Chilkat's MIME XML. The only argument is the XML string.
Background: Chilkat can represent a MIME tree as XML — headers as elements, parameters as attributes — which is convenient for inspecting or editing structure with XML tools. This is the inverse of
GetXml: it rebuilds the full MIME object from that representation. Invalid XML leaves the current object unchanged.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.LoadXml method, which reconstructs a MIME tree from Chilkat's MIME XML.
-- The only argument is the XML string.
DECLARE @mime int
EXEC @hr = sp_OACreate 'Chilkat.Mime', @mime OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Chilkat MIME XML (as produced by GetXml).
DECLARE @xmlText nvarchar(4000)
SELECT @xmlText = '<mime><contentType>text/plain</contentType><body>Hello.</body></mime>'
EXEC sp_OAMethod @mime, 'LoadXml', @success OUT, @xmlText
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