Sample code for 30+ languages & platforms
PowerBuilder

Example: Email.GetDsnInfo method

See more Email Object Examples

Demonstrates how to call the GetDsnInfo method.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Email
oleobject loo_Json
string ls_StrVal
string ls_Reporting_mta
string ls_Action
string ls_Status
string ls_Remote_mta
string ls_X_supplementary_info
string ls_X_display_name
integer i
integer li_Count

li_Success = 0

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/sample_multipart_report.eml")
if li_Success = 0 then
    Write-Debug loo_Email.LastErrorText
    destroy loo_Email
    return
end if

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

li_Success = loo_Email.GetDsnInfo(loo_Json)
if li_Success = 0 then
    Write-Debug loo_Email.LastErrorText
    destroy loo_Email
    destroy loo_Json
    return
end if

loo_Json.EmitCompact = 0
Write-Debug loo_Json.Emit()

// Sample output:

// {
//   "reporting-mta": "dns; Exchange2016.example.com",
//   "final-recipient": [
//     "herb.butterworth1247692846@gmail.com"
//   ],
//   "action": "failed",
//   "status": "5.1.1",
//   "remote-mta": "dns; mx.google.com",
//   "x-supplementary-info": "<mx.google.com #5.1.1 smtp;550-5.1.1 The email account that you tried to reach does not exist. Please try 550-5.1.1 double-checking the recipient's email address for typos or 550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1  https://support.google.com/mail/?p=NoSuchUser o8-20020a056870968800b001b55816bea9si2188132oaq.70 - gsmtp>",
//   "x-display-name": "herb.butterworth1247692846@gmail.com"
// }

// Code for parsing the JSON:

ls_Reporting_mta = loo_Json.StringOf("reporting-mta")
ls_Action = loo_Json.StringOf("action")
ls_Status = loo_Json.StringOf("status")
ls_Remote_mta = loo_Json.StringOf("remote-mta")
ls_X_supplementary_info = loo_Json.StringOf("x-supplementary-info")
ls_X_display_name = loo_Json.StringOf("x-display-name")
i = 0
li_Count = loo_Json.SizeOfArray("final-recipient")
do while i < li_Count
    loo_Json.I = i
    ls_StrVal = loo_Json.StringOf("final-recipient[i]")
    i = i + 1
loop


destroy loo_Email
destroy loo_Json