SQL Server
SQL Server
Get the Complete MIME Header of an Email
See more Email Object Examples
Demonstrates the read-only Chilkat Email.Header property, which returns the complete MIME header generated from the current in-memory email object. Because this property is read-only, you modify individual fields through their corresponding properties or header methods rather than assigning to Header directly. This example sets a subject, from, and recipient, then prints the full MIME header.
Background: A MIME email is made of two parts separated by a single blank line: the header and the body. The header is a list of
Field-Name: value lines — familiar ones include From, To, Subject, and Date, plus structural fields like Content-Type and MIME-Version. Reading the raw header is useful for debugging exactly what a message will look like on the wire.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
-- Demonstrates the read-only Email.Header property, which returns the
-- complete MIME header of the email, generated from the current in-memory
-- email object.
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', 'Test subject'
EXEC sp_OASetProperty @email, 'From', 'mary@example.com'
DECLARE @success int
EXEC sp_OAMethod @email, 'AddTo', @success OUT, 'Joe', 'joe@example.com'
-- Header is read-only. Modify individual fields through their properties
-- or header methods rather than assigning to Header.
EXEC sp_OAGetProperty @email, 'Header', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @email
END
GO