SQL Server
SQL Server
Load MIME from a StringBuilder
See more MIME Examples
Demonstrates the Chilkat Mime.LoadMimeSb method, which parses complete MIME text from a StringBuilder and replaces the current MIME. The only argument is the StringBuilder.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: When the MIME text already lives in a
StringBuilder — assembled in memory, or read and lightly edited — this loads it directly without an intermediate string copy. Its parsing behavior matches LoadMime; the difference is purely the source. For content that might include arbitrary binary bytes, use the BinData loader instead.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.LoadMimeSb method, which parses complete MIME text from a StringBuilder
-- and replaces the current MIME. The only argument is the StringBuilder.
-- Put the MIME text into a StringBuilder (here loaded from a file, but it could come from
-- anywhere).
DECLARE @sb int
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sb OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OAMethod @sb, 'LoadFile', @success OUT, 'qa_data/message.eml', 'utf-8'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @sb, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @sb
RETURN
END
DECLARE @mime int
EXEC @hr = sp_OACreate 'Chilkat.Mime', @mime OUT
EXEC sp_OAMethod @mime, 'LoadMimeSb', @success OUT, @sb
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @mime, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @sb
EXEC @hr = sp_OADestroy @mime
RETURN
END
EXEC sp_OAGetProperty @mime, 'ContentType', @sTmp0 OUT
PRINT 'Content-Type: ' + @sTmp0
EXEC @hr = sp_OADestroy @sb
EXEC @hr = sp_OADestroy @mime
END
GO