Sample code for 30+ languages & platforms
SQL Server

Count the Cc Recipients of an Email

See more Email Object Examples

Demonstrates the read-only Chilkat Email.NumCC property, which is the number of carbon-copy (Cc) recipients. Cc recipient indexes are zero-based and can be inspected with GetCC, GetCcAddr, and GetCcName. This example adds two Cc recipients and prints the count.

Background: The term "carbon copy" predates email — it comes from the carbon paper once used to make duplicate copies of typed letters. In email, Cc recipients receive a visible copy of the message and, by convention, are people who should be kept informed but are not the primary audience (that role belongs to the To recipients). All To and Cc addresses are visible to every recipient.

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    --  Demonstrates the read-only Email.NumCC property, which is the number of
    --  carbon-copy (Cc) recipients.  Cc 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, 'AddCC', @success OUT, 'Joe', 'joe@example.com'
    EXEC sp_OAMethod @email, 'AddCC', @success OUT, 'Jane', 'jane@example.com'


    EXEC sp_OAGetProperty @email, 'NumCC', @iTmp0 OUT
    PRINT 'NumCC = ' + @iTmp0

    EXEC @hr = sp_OADestroy @email


END
GO