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

Create a message disposition notification

See more Email Object Examples

An MDN describes a recipient-side event such as displaying a message. Create one only when the application has an appropriate request and the recipient has consented. Set Final-Recipient from the actual receiving mailbox. MDN format.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoEmail
    Handle hoFields
    String sOriginalId
    Variant vReport
    Handle hoReport
    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 "message.eml" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatXml)) To hoFields
    If (Not(IsComObjectCreated(hoFields))) Begin
        Send CreateComObject of hoFields
    End
    Set ComTag Of hoFields To "DispositionFields"
    Send ComNewChild2 To hoFields "Final-Recipient" "rfc822; alex@example.net"
    Get ComGetHeaderField Of hoEmail "Message-ID" To sOriginalId
    If (sOriginalId <> "") Begin
        Send ComNewChild2 To hoFields "Original-Message-ID" sOriginalId
    End

    Send ComNewChild2 To hoFields "Disposition" "manual-action/MDN-sent-manually; displayed"
    Get Create (RefClass(cComChilkatEmail)) To hoReport
    If (Not(IsComObjectCreated(hoReport))) Begin
        Send CreateComObject of hoReport
    End
    Get ComGetXml Of hoFields To sTemp1
    Get pvComObject of hoReport to vReport
    Get ComToMdn Of hoEmail "The recipient displayed your message." sTemp1 True vReport To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Set ComFrom Of hoReport To "Alex Rivera <alex@example.net>"

    Get ComSaveEml Of hoReport "disposition.eml" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoReport To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Saved disposition.eml."


End_Procedure