SQL Server
SQL Server
Set the Sender Email Address
See more Email Object Examples
Demonstrates the Chilkat Email.FromAddress property, which is the email address of the sender. Changing this property updates the address portion of the MIME From header while preserving the sender name when possible. This example sets the sender name and address separately, then reads back the combined From header.
Background: A
From header has two parts: the display name (e.g. John Smith) and the email address (e.g. john.smith@example.com). Only the address is used to actually route the message; the display name is cosmetic. Chilkat lets you manipulate each part independently through FromAddress and FromName, or the whole thing at once through From.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
-- Demonstrates the Email.FromAddress property (the email address of the sender).
-- Setting it updates the address portion of the From header while preserving
-- the sender name when possible.
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, 'FromName', 'John Smith'
EXEC sp_OASetProperty @email, 'FromAddress', 'john.smith@example.com'
EXEC sp_OAGetProperty @email, 'FromAddress', @sTmp0 OUT
PRINT 'FromAddress = ' + @sTmp0
EXEC sp_OAGetProperty @email, 'From', @sTmp0 OUT
PRINT 'From = ' + @sTmp0
EXEC @hr = sp_OADestroy @email
END
GO