SQL Server
SQL Server
Set the Email From Header
See more Email Object Examples
Demonstrates the Chilkat Email.From property, which contains the sender name and email address as they appear in the MIME From header, such as John Smith <john.smith@example.com>. The From, FromName, and FromAddress properties are different views of the same MIME From header. This example sets From and reads back all three views.
Background: The internet message standard (RFC 5322) formats a sender as an optional display name followed by the address in angle brackets:
Display Name <user@domain>. The display name is what a mail client typically shows in the inbox, while the bracketed address is the actual routing destination. Note that this visible From header is separate from the SMTP envelope sender used during delivery, which is why spoofing a From is possible — and why standards like SPF, DKIM, and DMARC exist to verify it.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
-- Demonstrates the Email.From property, which contains the sender name and
-- email address as they appear in the From header, such as
-- "John Smith <john.smith@example.com>".
-- From, FromName, and FromAddress are different views of the same From header.
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, 'From', 'John Smith <john.smith@example.com>'
EXEC sp_OAGetProperty @email, 'From', @sTmp0 OUT
PRINT 'From = ' + @sTmp0
EXEC sp_OAGetProperty @email, 'FromName', @sTmp0 OUT
PRINT 'FromName = ' + @sTmp0
EXEC sp_OAGetProperty @email, 'FromAddress', @sTmp0 OUT
PRINT 'FromAddress = ' + @sTmp0
EXEC @hr = sp_OADestroy @email
END
GO