SQL Server
SQL Server
Get the Full MIME of an Email
See more Email Object Examples
Demonstrates the Chilkat Email.GetMime method, which returns the email as RFC822/MIME text containing the headers, body representations, related items, and attachments. The result is suitable for saving as a .eml file. This example builds a message and prints its MIME.
Background: MIME is the on-the-wire text format of an email — the exact bytes a mail server sends and receives.
GetMime serializes the in-memory Email object into that format, assembling headers, encoding attachments as Base64, and adding the multipart boundaries that separate the parts. It is the natural way to persist a message (as .eml), inspect exactly what will be transmitted, or hand the message to another system.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
-- Demonstrates the GetMime method, which returns the email as RFC822/MIME text containing
-- the headers, body representations, related items, and attachments.
DECLARE @email int
EXEC @hr = sp_OACreate 'Chilkat.Email', @email OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OASetProperty @email, 'Subject', 'GetMime example'
EXEC sp_OASetProperty @email, 'From', 'alice@example.com'
DECLARE @success int
EXEC sp_OAMethod @email, 'AddTo', @success OUT, 'Bob', 'bob@example.com'
EXEC sp_OASetProperty @email, 'Body', 'Hello, this is the message body.'
-- Get the complete RFC822/MIME text (suitable for saving as a .eml file).
EXEC sp_OAMethod @email, 'GetMime', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @email
END
GO