SQL Server
SQL Server
Set the Sender Display Name
See more Email Object Examples
Demonstrates the Chilkat Email.FromName property, which is the display name of the sender. Changing this property updates the display-name portion of the MIME From header while preserving the email address. This example sets the address and display name separately, then reads back the combined From header.
Background: The display name is the friendly label a mail client shows instead of the raw address — for example, showing
John Smith rather than john.smith@example.com. It is purely cosmetic and plays no part in message routing; the same address can be paired with any display name. When a display name contains special characters or non-ASCII text, it must be quoted or MIME-encoded in the header, which Chilkat handles for you.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
-- Demonstrates the Email.FromName property (the name of the sender).
-- Setting it updates the display-name portion of the From header while
-- preserving the email address.
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, 'FromAddress', 'john.smith@example.com'
EXEC sp_OASetProperty @email, 'FromName', 'John Smith'
EXEC sp_OAGetProperty @email, 'FromName', @sTmp0 OUT
PRINT 'FromName = ' + @sTmp0
EXEC sp_OAGetProperty @email, 'From', @sTmp0 OUT
PRINT 'From = ' + @sTmp0
EXEC @hr = sp_OADestroy @email
END
GO