DataFlex
DataFlex
Get Delivery-Status Info as JSON
See more Email Object Examples
Demonstrates the Chilkat Email.GetDsnInfo method, which — when IsMultipartReport indicates the email is a multipart/report — obtains the delivery-status information as a JsonObject. This example loads a bounce message, confirms it is a report, and prints the extracted DSN details as JSON.
Background: A bounce (DSN) carries its key facts — which recipient failed, the status code, the reporting server — in a machine-readable
message/delivery-status part. Rather than parsing those raw fields yourself, GetDsnInfo gathers them into a structured JSON document you can query with the JsonObject API, making it easy to automate bounce handling and prune failed addresses from a mailing list.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoEmail
Variant vJson
Handle hoJson
String sTemp1
Boolean bTemp1
Move False To iSuccess
// Demonstrates the GetDsnInfo method, which, for a multipart/report email, obtains the
// delivery-status information as a JSON object.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Get ComLoadEml Of hoEmail "qa_data/eml/dsn_bounce.eml" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
// Only meaningful for a multipart/report email.
Get ComIsMultipartReport Of hoEmail To bTemp1
If (bTemp1 = True) Begin
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get pvComObject of hoJson to vJson
Get ComGetDsnInfo Of hoEmail vJson To iSuccess
If (iSuccess = True) Begin
Get ComEmit Of hoJson To sTemp1
Showln sTemp1
End
End
Else Begin
Showln "This email is not a multipart/report."
End
// Note: The path "qa_data/..." is a relative local filesystem path,
// relative to the current working directory of the running application.
End_Procedure