Sample code for 30+ languages & platforms
SQL Server

Clear the Cc Recipients of an Email

See more Email Object Examples

Demonstrates the Chilkat Email.ClearCC method, which clears the list of carbon-copy (Cc) recipients. It changes only the current in-memory email object and does not affect messages already sent. This example adds two Cc recipients, clears them, and prints the count before and after.

Background: When an Email object is reused to send personalized messages, the Cc list from one send would otherwise carry over to the next. ClearCC resets just that list, letting you re-populate it per recipient while keeping the rest of the message intact. It is the counterpart to ClearTo and ClearBcc.

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    --  Demonstrates the ClearCC method, which clears the list of carbon-copy (Cc) recipients.
    --  This changes only the current email object.

    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 before clear = ' + @iTmp0

    --  Remove all Cc recipients.
    EXEC sp_OAMethod @email, 'ClearCC', NULL


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

    EXEC @hr = sp_OADestroy @email


END
GO