SQL Server
SQL Server
Add Multiple To Recipients at Once
See more Email Object Examples
Demonstrates the Chilkat Email.AddMultipleTo method, which parses a comma-separated list of mailbox addresses and appends them all to the direct-recipient (To) list. Each entry may include a display name (e.g. Joe <joe@example.com>). This example adds three To recipients in a single call.
Background: The
To header holds a message's primary recipients, and email allows any number of them as a comma-separated list. AddMultipleTo parses that standard syntax — accepting both bare addresses and named forms — so when your recipients arrive as one string (from a form field, database column, or config value) you can populate the whole To list in one step instead of calling AddTo per recipient.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Demonstrates the AddMultipleTo method, which parses a comma-separated list of
-- addresses and appends them all to the direct-recipient (To) list.
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', 'Multiple To example'
EXEC sp_OASetProperty @email, 'From', 'alice@example.com'
-- Add several To recipients at once. Each entry may include a display name.
DECLARE @success int
EXEC sp_OAMethod @email, 'AddMultipleTo', @success OUT, 'Joe <joe@example.com>, jane@example.com, Bob <bob@example.com>'
EXEC sp_OAGetProperty @email, 'NumTo', @iTmp0 OUT
PRINT 'NumTo = ' + @iTmp0
EXEC @hr = sp_OADestroy @email
END
GO