SQL Server
SQL Server
Load an Email from a Chilkat XML File
See more Email Object Examples
Demonstrates the Chilkat Email.LoadXml method, which loads an email from a Chilkat XML email file (as produced by SaveXml). On success, the loaded message replaces the entire current email, including recipients, headers, bodies, related items, and attachments. This example loads the XML and reads its subject and from.
Background: Chilkat's XML email format is one way to persist a message — an alternative to the standard
.eml (MIME) format. It is worth knowing that .eml also preserves Chilkat-specific metadata: header fields whose names begin with CKX- are stored in the saved MIME and restored on load, and are simply always removed before an email is actually sent. Because .eml is the universal, interoperable format and captures the same metadata, Chilkat recommends using .eml (LoadEml / SaveEml) over the XML format — even within Chilkat-based software.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- Demonstrates the LoadXml method, which loads an email from a Chilkat XML email file.
-- On success, the loaded message replaces the entire current email.
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_OAMethod @email, 'LoadXml', @success OUT, 'qa_data/xml/email.xml'
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @email, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @email
RETURN
END
EXEC sp_OAGetProperty @email, 'Subject', @sTmp0 OUT
PRINT 'Subject: ' + @sTmp0
EXEC sp_OAGetProperty @email, 'From', @sTmp0 OUT
PRINT 'From: ' + @sTmp0
-- Note: The path "qa_data/..." is a relative local filesystem path,
-- relative to the current working directory of the running application.
EXEC @hr = sp_OADestroy @email
END
GO