SQL Server
SQL Server
Load an Email from a .eml File
See more Email Object Examples
Demonstrates the Chilkat Email.LoadEml method, which loads a complete email from an .eml file. An EML file contains RFC822/MIME message text. On success, the loaded message replaces the entire current email — recipients, headers, bodies, related items, and attachments. This example loads an EML and reads its subject and from.
Background:
.eml is the standard on-disk format for a single email — it is simply the raw MIME saved to a file, which most mail clients can export and open. LoadEml parses that MIME into a fully populated Email object, giving you programmatic access to every part. It is the natural counterpart to SaveEml.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
-- Demonstrates the LoadEml method, which loads a complete email from an .eml file (an EML
-- file contains RFC822/MIME message text). 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, 'LoadEml', @success OUT, 'qa_data/eml/message.eml'
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