![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) Create DSN (Delivery Status Notification) EmailSee more Email Object ExamplesDemonstrates how to create a DSN (Delivery Status Notification) Email having the format as defined in RFC 3464.Note: This example requires Chilkat v11.0.0 or greater.
LOCAL loEmail LOCAL loXml LOCAL loDtNow LOCAL lnHeaderOnly LOCAL loSbText LOCAL lcExplain LOCAL loDsnEmail LOCAL lnSuccess * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Email') loEmail = CreateObject('Chilkat.Email') loEmail.Subject = "Test" loEmail.From = "joe@example.com" loEmail.Body = "This is a test" loEmail.AddTo("","recipient@example.com") ? loEmail.GetMime() ? "" ? "-------------------------------------------------------------" ? "" * This is the email we just created: * MIME-Version: 1.0 * Date: Mon, 12 May 2025 11:13:15 -0500 * Message-ID: <917FA49F75544EF51948B0A52F403B925B51073F@SLICE> * Content-Type: text/plain; charset=us-ascii; format=flowed * Content-Transfer-Encoding: 7bit * X-Priority: 3 (Normal) * Subject: Test * From: joe@example.com * To: recipient@example.com * * This is a test * ----------------------------------------------------------------- * Convert the above email into a DSN (Delivery Status Notification) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Xml') loXml = CreateObject('Chilkat.Xml') loXml.Tag = "DeliveryStatusFields" loXml.NewChild2("Final-Recipient","rfc822; recipient@example.com") loXml.NewChild2("Action","failed") loXml.NewChild2("Status","5.1.2") loXml.NewChild2("Diagnostic-Code","smtp; 550 5.1.2 Host unknown (Domain name not found)") * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.CkDateTime') loDtNow = CreateObject('Chilkat.CkDateTime') loDtNow.SetFromCurrentSystemTime() loXml.NewChild2("Last-Attempt-Date",loDtNow.GetAsRfc822(1)) lnHeaderOnly = 1 * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbText = CreateObject('Chilkat.StringBuilder') loSbText.Append("This is an automatically generated Delivery Status Notification." + CHR(13) + CHR(10) + CHR(13) + CHR(10)) loSbText.Append("Delivery to the following recipient failed permanently:" + CHR(13) + CHR(10) + CHR(13) + CHR(10)) loSbText.Append(" recipient@example.com" + CHR(13) + CHR(10) + CHR(13) + CHR(10)) loSbText.Append("Technical details of permanent failure:" + CHR(13) + CHR(10)) loSbText.Append("DNS Error: Domain name not found" + CHR(13) + CHR(10)) lcExplain = loSbText.GetAsString() * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Email') loDsnEmail = CreateObject('Chilkat.Email') lnSuccess = loEmail.ToDsn(lcExplain,loXml.GetXml(),lnHeaderOnly,loDsnEmail) IF (lnSuccess = 0) THEN ? loEmail.LastErrorText RELEASE loEmail RELEASE loXml RELEASE loDtNow RELEASE loSbText RELEASE loDsnEmail CANCEL ENDIF ? loDsnEmail.GetMime() * Here's the MIME of the DNS email we just created: * ------------------------------------------------- * Content-Type: multipart/report; report-type="delivery-status"; boundary="------------060100020300020303000802" * * --------------060100020300020303000802 * Content-Type: text/plain; charset=windows-1252; format=flowed * Content-Transfer-Encoding: 7bit * * This is an automatically generated Delivery Status Notification. * * Delivery to the following recipient failed permanently: * * recipient@example.com * * Technical details of permanent failure: * DNS Error: Domain name not found * * --------------060100020300020303000802 * Content-Type: message/delivery-status * * Final-Recipient: rfc822; recipient@example.com * Action: failed * Status: 5.1.2 * Diagnostic-Code: smtp; 550 5.1.2 Host unknown (Domain name not found) * Last-Attempt-Date: Mon, 12 May 2025 11:30:39 -0500 * * --------------060100020300020303000802 * Content-Type: text/rfc822-headers; charset=windows-1252 * * MIME-Version: 1.0 * Date: Mon, 12 May 2025 11:30:39 -0500 * Message-ID: <B8E6875D582A78AE779FC0B46ACC8C858CEAF608@SLICE> * Content-Type: text/plain; charset=us-ascii; format=flowed * Content-Transfer-Encoding: 7bit * X-Priority: 3 (Normal) * Subject: Test * From: joe@example.com * To: recipient@example.com * --------------060100020300020303000802-- RELEASE loEmail RELEASE loXml RELEASE loDtNow RELEASE loSbText RELEASE loDsnEmail |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.