Sample code for 30+ languages & platforms
SQL Server

Add a Cc Recipient to an Email

See more Email Object Examples

Demonstrates the Chilkat Email.AddCC method, which adds a single carbon-copy (Cc) recipient. The first argument is the friendly display name and the second is the email address. This example adds one Cc recipient and prints the resulting count.

Background: Cc ("carbon copy") recipients receive a visible copy of the message and, unlike Bcc, their addresses appear in the delivered headers for all recipients to see. By convention, To is for the people expected to act on the message and Cc is for those who should be kept in the loop. Functionally the mail server delivers to To and Cc addresses identically — the distinction is one of etiquette and intent.

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    --  Demonstrates the AddCC method, which adds a single carbon-copy (Cc) recipient.
    --  The 1st argument is the friendly (display) name, and the 2nd is 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, 'Subject', 'Cc example'
    EXEC sp_OASetProperty @email, 'From', 'alice@example.com'

    DECLARE @success int
    EXEC sp_OAMethod @email, 'AddCC', @success OUT, 'Joe', 'joe@example.com'


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

    EXEC @hr = sp_OADestroy @email


END
GO