Chilkat Examples

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

Visual Basic 6.0 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

 

 

 

(Visual Basic 6.0) Create DSN (Delivery Status Notification) Email

See more Email Object Examples
Demonstrates 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.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Dim email As New ChilkatEmail

email.Subject = "Test"
email.From = "joe@example.com"
email.Body = "This is a test"
success = email.AddTo("","recipient@example.com")

Debug.Print email.GetMime()
Debug.Print ""
Debug.Print "-------------------------------------------------------------"
Debug.Print ""

' 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)

Dim xml As New ChilkatXml
xml.Tag = "DeliveryStatusFields"
xml.NewChild2 "Final-Recipient","rfc822; recipient@example.com"
xml.NewChild2 "Action","failed"
xml.NewChild2 "Status","5.1.2"
xml.NewChild2 "Diagnostic-Code","smtp; 550 5.1.2 Host unknown (Domain name not found)"
Dim dtNow As New CkDateTime
success = dtNow.SetFromCurrentSystemTime()
xml.NewChild2 "Last-Attempt-Date",dtNow.GetAsRfc822(1)

Dim headerOnly As Long
headerOnly = 1
Dim sbText As New ChilkatStringBuilder
success = sbText.Append("This is an automatically generated Delivery Status Notification." & vbCrLf & vbCrLf)
success = sbText.Append("Delivery to the following recipient failed permanently:" & vbCrLf & vbCrLf)
success = sbText.Append("    recipient@example.com" & vbCrLf & vbCrLf)
success = sbText.Append("Technical details of permanent failure:" & vbCrLf)
success = sbText.Append("DNS Error: Domain name not found" & vbCrLf)

Dim explain As String
explain = sbText.GetAsString()

Dim dsnEmail As New ChilkatEmail
Dim success As Long
success = email.ToDsn(explain,xml.GetXml(),headerOnly,dsnEmail)
If (success = 0) Then
    Debug.Print email.LastErrorText
    Exit Sub
End If

Debug.Print dsnEmail.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--

 

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