PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Email
oleobject loo_Json
li_Success = 0
// Demonstrates the GetDsnInfo method, which, for a multipart/report email, obtains the
// delivery-status information as a JSON object.
loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
destroy loo_Email
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Email.LoadEml("qa_data/eml/dsn_bounce.eml")
if li_Success = 0 then
Write-Debug loo_Email.LastErrorText
destroy loo_Email
return
end if
// Only meaningful for a multipart/report email.
if loo_Email.IsMultipartReport() = 1 then
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
li_Success = loo_Email.GetDsnInfo(loo_Json)
if li_Success = 1 then
Write-Debug loo_Json.Emit()
end if
else
Write-Debug "This email is not a multipart/report."
end if
// Note: The path "qa_data/..." is a relative local filesystem path,
// relative to the current working directory of the running application.
destroy loo_Email
destroy loo_Json