DataFlex
DataFlex
Example: Email.GetDsnInfo method
See more Email Object Examples
Demonstrates how to call the GetDsnInfo method.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoEmail
Variant vJson
Handle hoJson
String sStrVal
String sReporting_mta
String sAction
String sStatus
String sRemote_mta
String sX_supplementary_info
String sX_display_name
Integer i
Integer iCount
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Get ComLoadEml Of hoEmail "qa_data/eml/sample_multipart_report.eml" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
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 = False) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Set ComEmitCompact Of hoJson To False
Get ComEmit Of hoJson To sTemp1
Showln sTemp1
// 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:
Get ComStringOf Of hoJson "reporting-mta" To sReporting_mta
Get ComStringOf Of hoJson "action" To sAction
Get ComStringOf Of hoJson "status" To sStatus
Get ComStringOf Of hoJson "remote-mta" To sRemote_mta
Get ComStringOf Of hoJson "x-supplementary-info" To sX_supplementary_info
Get ComStringOf Of hoJson "x-display-name" To sX_display_name
Move 0 To i
Get ComSizeOfArray Of hoJson "final-recipient" To iCount
While (i < iCount)
Set ComI Of hoJson To i
Get ComStringOf Of hoJson "final-recipient[i]" To sStrVal
Move (i + 1) To i
Loop
End_Procedure