Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples
Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
X
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) Transition from Email.GetDsnFinalRecipients to Email.GetDsnInfo

Provides instructions for replacing deprecated GetDsnFinalRecipients method calls with GetDsnInfo.

Note: This example requires Chilkat v11.0.0 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoEmail
    Boolean iSuccess
    Variant vSa
    Handle hoSa
    Integer i
    Integer iCount
    Variant vJson
    Handle hoJson
    String sRecipient
    String sTemp1
    Boolean bTemp1

    Get Create (RefClass(cComChilkatEmail)) To hoEmail
    If (Not(IsComObjectCreated(hoEmail))) Begin
        Send CreateComObject of hoEmail
    End

    // Load a multipart/report DSN email.
    Get ComLoadEml Of hoEmail "qa_data/eml/dsn_example.eml" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // ------------------------------------------------------------------------
    // The GetDsnFinalRecipients method is deprecated:

    Get ComGetDsnFinalRecipients Of hoEmail To vSa
    If (IsComObject(vSa)) Begin
        Get Create (RefClass(cComCkStringArray)) To hoSa
        Set pvComObject Of hoSa To vSa
    End
    Get ComLastMethodSuccess Of hoEmail To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Move 0 To i
    Get ComCount Of hoSa To iCount
    While (i < iCount)
        Get ComGetString Of hoSa i To sTemp1
        Showln i ": " sTemp1
        Move (i + 1) To i
    Loop

    Showln "----"

    Send Destroy of hoSa

    // ------------------------------------------------------------------------
    // Do the equivalent using GetDsnInfo.
    // Your application creates a new, empty JsonObject object which is passed 
    // in the last argument and filled upon success.

    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
    Showln "----"

    // The JSON contains the following:

    // {
    //   "reporting-mta": "dns; mail.example.com",
    //   "received-from-mta": "dns; smtp.example.com",
    //   "arrival-date": "Fri, 8 May 2025 14:23:42 -0400",
    //   "final-recipient": [
    //     "rfc822; alice@example.com",
    //     "rfc822; bob@example.com",
    //     "rfc822; carol@example.com"
    //   ],
    //   "action": "failed",
    //   "status": "5.1.1",
    //   "remote-mta": "dns; smtp.recipientdomain.com",
    //   "diagnostic-code": "smtp; 550 5.1.1 User unknown",
    //   "last-attempt-date": "Fri, 8 May 2025 14:23:42 -0400",
    //   "action": "failed",
    //   "status": "5.1.2",
    //   "remote-mta": "dns; smtp.recipientdomain.com",
    //   "diagnostic-code": "smtp; 550 5.1.2 Host unknown (Domain name not found)",
    //   "last-attempt-date": "Fri, 8 May 2025 14:23:42 -0400",
    //   "action": "failed",
    //   "status": "5.7.1",
    //   "remote-mta": "dns; smtp.recipientdomain.com",
    //   "diagnostic-code": "smtp; 550 5.7.1 Relay access denied",
    //   "last-attempt-date": "Fri, 8 May 2025 14:23:42 -0400"
    // }

    // Iterate over the final-recipients
    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 sRecipient
        Showln i ": " sRecipient

        Move (i + 1) To i
    Loop

    // -------------------------------------------------------------------------------------------
    // -------------------------------------------------------------------------------------------
    // This is the contents of the dsn_example.eml used for this example:

    // From: postmaster@example.com
    // To: sender@example.com
    // Subject: Delivery Status Notification (Failure)
    // MIME-Version: 1.0
    // Content-Type: multipart/report; report-type=delivery-status;
    //     boundary="boundary-string"
    // 
    // --boundary-string
    // Content-Type: text/plain; charset=us-ascii
    // 
    // This is an automatically generated Delivery Status Notification.
    // 
    // Delivery to the following recipients failed permanently:
    // 
    //     alice@example.com
    //     bob@example.com
    //     carol@example.com
    // 
    // Technical details of permanent failure:
    // DNS Error: Domain name not found
    // 
    // --boundary-string
    // Content-Type: message/delivery-status
    // 
    // Reporting-MTA: dns; mail.example.com
    // Received-From-MTA: dns; smtp.example.com
    // Arrival-Date: Fri, 8 May 2025 14:23:42 -0400
    // 
    // Final-Recipient: rfc822; alice@example.com
    // Action: failed
    // Status: 5.1.1
    // Remote-MTA: dns; smtp.recipientdomain.com
    // Diagnostic-Code: smtp; 550 5.1.1 User unknown
    // Last-Attempt-Date: Fri, 8 May 2025 14:23:42 -0400
    // 
    // Final-Recipient: rfc822; bob@example.com
    // Action: failed
    // Status: 5.1.2
    // Remote-MTA: dns; smtp.recipientdomain.com
    // Diagnostic-Code: smtp; 550 5.1.2 Host unknown (Domain name not found)
    // Last-Attempt-Date: Fri, 8 May 2025 14:23:42 -0400
    // 
    // Final-Recipient: rfc822; carol@example.com
    // Action: failed
    // Status: 5.7.1
    // Remote-MTA: dns; smtp.recipientdomain.com
    // Diagnostic-Code: smtp; 550 5.7.1 Relay access denied
    // Last-Attempt-Date: Fri, 8 May 2025 14:23:42 -0400
    // 
    // --boundary-string
    // Content-Type: message/rfc822
    // 
    // Return-Path: <sender@example.com>
    // Received: from smtp.example.com (smtp.example.com [192.168.1.10])
    //     by mail.example.com (Postfix) with ESMTP id 123456789
    //     for <alice@example.com>, <bob@example.com>, <carol@example.com>;
    //     Fri, 8 May 2025 14:23:42 -0400
    // Message-ID: <001a113d789f$ad34bc30$038e34b0$@example.com>
    // From: Sender Name <sender@example.com>
    // To: alice@example.com, bob@example.com, carol@example.com
    // Subject: Test Message
    // Date: Fri, 8 May 2025 14:20:00 -0400
    // Content-Type: text/plain; charset="us-ascii"
    // 
    // This is a test email message sent to multiple recipients.
    // --boundary-string--
    // 


End_Procedure

 

© 2000-2025 Chilkat Software, Inc. All Rights Reserved.