Sample code for 30+ languages & platforms
DataFlex

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 DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoEmail
    Boolean iSuccess
    Integer n
    Integer i
    String sTemp1

    //  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.

    Get Create (RefClass(cComChilkatEmail)) To hoEmail
    If (Not(IsComObjectCreated(hoEmail))) Begin
        Send CreateComObject of hoEmail
    End
    Set ComSubject Of hoEmail To "GetCcName example"

    Get ComAddCC Of hoEmail "Joe Smith" "joe@example.com" To iSuccess
    Get ComAddCC Of hoEmail "Jane Doe" "jane@example.com" To iSuccess

    Get ComNumCC Of hoEmail To n

    For i From 0 To (n - 1)
        Get ComGetCcName Of hoEmail i To sTemp1
        Showln "Cc " i " name: " sTemp1
    Loop



End_Procedure