SQL Server
SQL Server
Get a Header Field by Name
See more Email Object Examples
Demonstrates the Chilkat Email.GetHeaderField method, which returns the value of a header field by name. Header-field names are case-insensitive, so X-Priority and x-priority refer to the same field. This example reads several headers by name.
Background: Looking up a header by name is the quickest way to read a known field like
Subject or a custom X- header. One caveat: some header names (such as Received) can legitimately appear more than once. When a field may repeat and you need every occurrence, enumerate by index with GetHeaderFieldName and GetHeaderFieldValue instead of looking up by name.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
-- Demonstrates the GetHeaderField method, which returns the value of a header field by
-- name. Header-field names are case-insensitive.
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', 'Quarterly report'
EXEC sp_OASetProperty @email, 'From', 'alice@example.com'
EXEC sp_OAMethod @email, 'AddHeaderField', NULL, 'X-Priority', '1'
-- Get header field values by name.
EXEC sp_OAMethod @email, 'GetHeaderField', @sTmp0 OUT, 'Subject'
PRINT 'Subject = ' + @sTmp0
EXEC sp_OAMethod @email, 'GetHeaderField', @sTmp0 OUT, 'From'
PRINT 'From = ' + @sTmp0
EXEC sp_OAMethod @email, 'GetHeaderField', @sTmp0 OUT, 'x-priority'
PRINT 'X-Priority = ' + @sTmp0
EXEC @hr = sp_OADestroy @email
END
GO