Sample code for 30+ languages & platforms
DataFlex Requires Chilkat v11.0.0+

Send an email with a Bcc recipient using SMTP (live send)

See more Email Object Examples

Live send. Load the previously prepared with-attachments.eml, add a Bcc recipient, and pass the Email to MailMan.SendEmail. For a real test, use a relay you control, replace the sample sender and recipients (including the Bcc address) with test mailboxes, and obtain credentials from your application’s secret store.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Variant vEmail
    Handle hoEmail
    Handle hoMail
    String sTemp1

    Move False To iSuccess

    //  Assumes Chilkat is unlocked. See Global Unlock Sample.

    Get Create (RefClass(cComChilkatEmail)) To hoEmail
    If (Not(IsComObjectCreated(hoEmail))) Begin
        Send CreateComObject of hoEmail
    End
    Get ComLoadEml Of hoEmail "with-attachments.eml" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    //  Enable this option before adding a blind recipient to the message.
    Set ComUncommonOptions Of hoEmail To "NoBccHeader"
    Get ComAddBcc Of hoEmail "Bcc recipient" "bcc@example.net" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatMailMan)) To hoMail
    If (Not(IsComObjectCreated(hoMail))) Begin
        Send CreateComObject of hoMail
    End
    Set ComSmtpHost Of hoMail To "smtp.example.com"
    Set ComSmtpPort Of hoMail To 465
    Set ComSmtpSsl Of hoMail To True
    Set ComRequireSslCertVerify Of hoMail To True
    Set ComSmtpUsername Of hoMail To "MAIL_USER"
    Set ComSmtpPassword Of hoMail To "MAIL_PASSWORD"
    Get pvComObject of hoEmail to vEmail
    Get ComSendEmail Of hoMail vEmail To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoMail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "The SMTP relay accepted the message."
    Get ComCloseSmtpConnection Of hoMail To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoMail To sTemp1
        Showln sTemp1
        Procedure_Return
    End



End_Procedure