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

Set a MIME header on one attachment

See more Email Object Examples

Add a file using the content type required by the receiving application. Set Content-Description on the newly added MIME part and read it back from that part. The message-level headers have a separate collection.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoEmail
    Integer iIndex
    String sTemp1
    Integer iTemp1

    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
    Set ComFrom Of hoEmail To "Workshop team <events@example.com>"
    Get ComAddTo Of hoEmail "Alex Rivera" "alex@example.net" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Set ComSubject Of hoEmail To "Workshop registration"
    Set ComBody Of hoEmail To "Attached is the requested data file."
    Get ComAddFileAttachment2 Of hoEmail "sample.hpm" "application/x-hprimnet" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComNumAttachments Of hoEmail To iTemp1
    Move (iTemp1 - 1) To iIndex
    Send ComAddAttachmentHeader To hoEmail iIndex "Content-Description" "HPM/3.0"
    Get ComGetAttachmentHeader Of hoEmail iIndex "Content-Description" To sTemp1
    Showln sTemp1

    Get ComSaveEml Of hoEmail "described-attachment.eml" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Saved described-attachment.eml."


End_Procedure