SQL Server
SQL Server
Append a Part to a Multipart MIME Entity
See more MIME Examples
Demonstrates the Chilkat Mime.AppendPart method, which appends a copy of another Mime as the last direct child. The only argument is the source Mime. Chilkat copies it, so later changes to the source do not affect the appended part.
Background: This is the general way to build up a multipart entity from parts you construct yourself — a text body, an HTML body, a nested multipart. Because it appends a copy, you can reuse and modify the source object afterward, or append it more than once, without surprises. For attaching a file directly,
AppendPartFromFile is more convenient.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- Demonstrates the Mime.AppendPart method, which appends a copy of another Mime as the last direct
-- child. The only argument is the Mime to append. Chilkat copies it, so later changes to the
-- source do not affect the appended part.
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, 'NewMultipartMixed', @success OUT
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @mime, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @mime
RETURN
END
-- Build a part and append a copy of it.
DECLARE @part int
EXEC @hr = sp_OACreate 'Chilkat.Mime', @part OUT
EXEC sp_OAMethod @part, 'SetBodyFromPlainText', @success OUT, 'This is an appended 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, 'NumParts', @iTmp0 OUT
PRINT 'Number of parts: ' + @iTmp0
EXEC @hr = sp_OADestroy @mime
EXEC @hr = sp_OADestroy @part
END
GO