Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

PureBasic Examples

ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
FileAccess
Firebase
GMail REST API
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Sheets
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)
Jira
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Shopify
Socket/SSL/TLS
Spider
Stream
Stripe
SugarCRM
Tar Archive
Twitter
Upload
VoiceBase
Walmart
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(PureBasic) Create MDN (Message Disposition Notification) Email

Demonstrates how to create a MDN (Message Disposition Notification) Email having the format as defined in RFC 3798.

Chilkat PureBasic Module Download

Chilkat PureBasic Module

IncludeFile "CkEmail.pb"
IncludeFile "CkXml.pb"

Procedure ChilkatExample()

    email.i = CkEmail::ckCreate()
    If email.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    ;  An MDN can be used to notify the
    ;  sender of a message of any of several conditions that may occur after
    ;  successful delivery, such as display of the message contents,
    ;  printing of the message, deletion (without display) of the message,
    ;  or the recipient's refusal to provide MDNs.
    ;  (for more information, see RFC 3798)

    ;  IMPORTANT:
    ;  Note: Please be careful in sending automated MDN's.
    ;  It is important to be aware of an issue called "backscatter".
    ;  See the Wikipedia article here:  http://en.wikipedia.org/wiki/Backscatter_%28e-mail%29

    ;  The CreateMdn method is called to create a new
    ;  MDN email based upon the email object calling CreateMdn.
    ;  The email object instance used to call CreateMdn would
    ;  typically be an email received from a POP3 or IMAP server.
    ;  In this case, to simplify the example, we'll load the email
    ;  from a .eml file.

    ;  This example will be creating a MDN for "someEmail.eml"
    success = CkEmail::ckLoadEml(email,"someEmail.eml")
    If success <> 1
        Debug CkEmail::ckLastErrorText(email)
        CkEmail::ckDispose(email)
        ProcedureReturn
    EndIf

    ;  The MDN created by CreateMdn will contain a
    ;  "message/disposition-notification" MIME sub-part that will
    ;  be composed of a number of name-value pairs.
    ;  See RFC 3798  ( http://tools.ietf.org/html/rfc3798 )
    ;  The name-value content for this part is passed
    ;  as XML to CreateMdn. This part of the example
    ;  prepares the XML:
    xml.i = CkXml::ckCreate()
    If xml.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ;  For this example, we're just adding a few name-value pairs.
    ;  These should not be considered to be correct, required or
    ;  even sensible -- they are simply for the example.
    CkXml::setCkTag(xml, "DispositionFields")
    CkXml::ckNewChild2(xml,"Disposition","manual-action/MDN-sent-manually; displayed")
    CkXml::ckNewChild2(xml,"Original-Message-ID",CkEmail::ckGetHeaderField(email,"Message-ID"))
    CkXml::ckNewChild2(xml,"Final-Recipient",CkEmail::ckGetToAddr(email,0))

    xmlStr.s = CkXml::ckGetXml(xml)

    ;  The last argument to be passed to CreateMdn will be a boolean
    ;  indicating whether to include the entire MIME of the calling
    ;  email object in the MDN, or only the header.
    ;  It may make sense to include the entire email for small emails,
    ;  but for large emails (with large attachments) it's probably
    ;  best to make the MDN header-only.
    bHeaderOnly.i = 1

    ;  The first argument to be passed to CreateMdn will
    ;  be a human-readable explanation that will be placed
    ;  into the 1st MIME part of the MDN (see RFC 3798).
    humanReadableExplanation.s = "Blah blah blah.  Your message has been received and displayed. Blah blah blah"

    ;  OK, we're ready to create MDN...
    mdnEmail.i

    mdnEmail = CkEmail::ckCreateMdn(email,humanReadableExplanation,xmlStr,bHeaderOnly)

    If Not (mdnEmail = 0)
        ;  Show the MIME of the source (original) email:
        Debug CkEmail::ckGetMime(email)

        Debug "**************************************"

        ;  Show the MIME of the MDN email:
        Debug CkEmail::ckGetMime(mdnEmail)
    Else
        Debug CkEmail::ckLastErrorText(email)
    EndIf

    CkEmail::ckDispose(mdnEmail)

    ;  Sample output showing the MIME of the original email,
    ;  and the MDN email created based upon it:

    ; --1--


    CkEmail::ckDispose(email)
    CkXml::ckDispose(xml)


    ProcedureReturn
EndProcedure

 

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