Sample code for 30+ languages & platforms
DataFlex

Request a Return Receipt for an Email

See more Email Object Examples

Demonstrates the Chilkat Email.ReturnReceipt property. Set it to true to request a return-receipt when the message is received; this causes a Disposition-Notification-To header to be added when the email is sent. The default is false. This example enables the request.

Background: A return receipt (technically a Message Disposition Notification, MDN) asks the recipient's mail client to send back a small confirmation when the message is opened. It is only a request: the receiving client or server is free to ignore it, and many prompt the user before sending anything. Because of this, a return receipt is not reliable proof that a human actually read the message — treat it as a courtesy signal, not a guarantee.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoEmail
    Boolean iSuccess
    Boolean bTemp1

    //  Demonstrates the Email.ReturnReceipt property.  Set to true to request a
    //  return-receipt when the email is received.  This causes a Disposition-Notification-To
    //  header to be added when the email is sent.  The default is false.

    Get Create (RefClass(cComChilkatEmail)) To hoEmail
    If (Not(IsComObjectCreated(hoEmail))) Begin
        Send CreateComObject of hoEmail
    End
    Set ComSubject Of hoEmail To "Please confirm receipt"
    Set ComBody Of hoEmail To "Kindly confirm you received this message."
    Set ComFrom Of hoEmail To "alice@example.com"
    Get ComAddTo Of hoEmail "Bob" "bob@example.com" To iSuccess

    //  Request a return receipt.
    Set ComReturnReceipt Of hoEmail To True

    Get ComReturnReceipt Of hoEmail To bTemp1
    Showln "ReturnReceipt = " bTemp1


End_Procedure