SQL Server
SQL Server
Count the To Recipients of an Email
See more Email Object Examples
Demonstrates the read-only Chilkat Email.NumTo property, which is the number of direct "To" recipients. To-recipient indexes are zero-based and can be inspected with GetTo, GetToAddr, and GetToName. This example adds three To recipients and prints the count.
Background: The
To header lists the message's primary recipients — the people the email is directly addressed to and expected to act on it. A single email can have any number of To addresses, and each is stored as a display name plus an email address. Together with NumCC and NumBcc, this property lets you inspect the full recipient set of a message.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Demonstrates the read-only Email.NumTo property, which is the number of direct
-- "To" recipients. To-recipient indexes are zero-based.
DECLARE @email int
EXEC @hr = sp_OACreate 'Chilkat.Email', @email OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
EXEC sp_OAMethod @email, 'AddTo', @success OUT, 'Joe', 'joe@example.com'
EXEC sp_OAMethod @email, 'AddTo', @success OUT, 'Jane', 'jane@example.com'
EXEC sp_OAMethod @email, 'AddTo', @success OUT, 'Bob', 'bob@example.com'
EXEC sp_OAGetProperty @email, 'NumTo', @iTmp0 OUT
PRINT 'NumTo = ' + @iTmp0
EXEC @hr = sp_OADestroy @email
END
GO