Sample code for 30+ languages & platforms
SQL Server

Get a Cc Recipient's Name Only

See more Email Object Examples

Demonstrates the Chilkat Email.GetCcName method, which returns only the friendly-name part (not the address) of the Nth carbon-copy recipient. The index is zero-based. This example adds two Cc recipients and prints each one's display name.

Background: A recipient combines a display name with an address, such as Jane Doe <jane@example.com>. GetCcName returns just the Jane Doe portion, which is handy for showing a friendly label in a UI. The name is optional free-form text, so it may be empty — when it is, fall back to the address from GetCcAddr.

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @sTmp0 nvarchar(4000)
    --  Demonstrates the GetCcName method, which returns only the friendly-name part (not the
    --  address) of the Nth carbon-copy recipient.  The index is 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

    EXEC sp_OASetProperty @email, 'Subject', 'GetCcName example'

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

    DECLARE @n int
    EXEC sp_OAGetProperty @email, 'NumCC', @n OUT
    DECLARE @i int

    SELECT @i = 0
    WHILE @i <= @n - 1
      BEGIN


        EXEC sp_OAMethod @email, 'GetCcName', @sTmp0 OUT, @i
        PRINT 'Cc ' + @i + ' name: ' + @sTmp0
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @email


END
GO