PowerBuilder
PowerBuilder
Count the Report Parts in a multipart/report Email
See more Email Object Examples
Demonstrates the read-only Chilkat Email.NumReports property, which is the number of report parts in a multipart/report email. A part is counted as a report when its Content-Type is message/* (except message/rfc822) or text/rfc822-headers. Use GetReport to retrieve the body of each report part; indexes are zero-based. This example loads a report email and prints each report part.
Background: When a message can't be delivered, the mail system usually sends back a bounce known as a Delivery Status Notification (DSN). DSNs use the
multipart/report structure, which bundles several parts: a human-readable explanation, a machine-readable message/delivery-status part describing exactly what happened (recipient, status code, failing server), and often the original message's headers. Reading these report parts lets a program automatically detect and process bounces.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Email
integer n
integer i
li_Success = 0
// Demonstrates the read-only Email.NumReports property, which is the number of report
// parts in a multipart/report email (for example, a Delivery Status Notification).
// Use GetReport to retrieve the body of each report part. Indexes are zero-based.
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
// Load a multipart/report email (such as a bounce / DSN message).
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
n = loo_Email.NumReports
Write-Debug "NumReports = " + string(n)
for i = 0 to n - 1
Write-Debug "---- Report " + string(i) + " ----"
Write-Debug loo_Email.GetReport(i)
next
destroy loo_Email