Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicPythonRubySQL ServerSwiftTclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcel

PowerBuilder Examples


ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
Firebase
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
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
VoiceBase
Walmart
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(PowerBuilder) Load .eml and Examine the Structure, Attachments, and Related Items

Demonstrates how to load examine the MIME structure of a .eml, and also examine the attachment and related item filenames, attached messages, and multipart/report and DSN information.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
string ls_EmlPath
oleobject loo_Mime
integer li_Success
oleobject loo_Email
integer i
integer li_NumAttach
integer li_NumRelated
integer li_NumAttachedMessages
oleobject loo_Em
integer li_NumReports
oleobject loo_Sa
integer li_NumFinalRecipients

//  This example assumes Chilkat Mime to have been previously unlocked.
//  See Unlock Mime for sample code.

ls_EmlPath = "C:/AAWorkarea/beatrix/roesner.eml"

loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat_9_5_0.Mime")
if li_rc < 0 then
    destroy loo_Mime
    MessageBox("Error","Connecting to COM object failed")
    return
end if

li_Success = loo_Mime.LoadMimeFile(ls_EmlPath)
if li_Success <> 1 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Mime
    return
end if

Write-Debug "---- MIME structure ----"
Write-Debug loo_Mime.GetStructure("text")
Write-Debug "------------------------"

loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat_9_5_0.Email")

li_Success = loo_Email.LoadEml(ls_EmlPath)

//  Was this a signed and/or encrypted email?
//  If so, then loading the .eml automatically unwraps
//  (i.e. verifies signatures and decrypts) and the resultant
//  email is what existed prior to signing/encrypting.
Write-Debug "Email was Signed: " + string(loo_Email.ReceivedSigned)
Write-Debug "Email was Encrypted: " + string(loo_Email.ReceivedEncrypted)
if loo_Email.ReceivedSigned = 1 then
    Write-Debug "Signature(s) valid = " + string(loo_Email.SignaturesValid)
end if

if loo_Email.ReceivedEncrypted = 1 then
    Write-Debug "Decrypted successfully = " + string(loo_Email.Decrypted)
end if

i = 0
li_NumAttach = loo_Email.NumAttachments
Write-Debug "Number of attachments = " + string(li_NumAttach)

do while i < li_NumAttach
    Write-Debug "---- Attachment " + string(i)

    //  Examine the filename (if any)
    Write-Debug "filename: " + loo_Email.GetAttachmentFilename(i)
    //  Examine the content-ID (if any)
    Write-Debug "Content-ID: " + loo_Email.GetAttachmentContentID(i)
    //  Examine the content-type
    Write-Debug "Content-Type: " + loo_Email.GetAttachmentContentType(i)
    //  Examine the content-disposition
    Write-Debug "Content-Disposition" + loo_Email.GetAttachmentHeader(i,"content-disposition")
    //  Examine the attachment size:
    Write-Debug "Size (in bytes) of the attachment: " + string(loo_Email.GetAttachmentSize(i))

    i = i + 1
loop
Write-Debug "--"

//  Now for the related items.
li_NumRelated = loo_Email.NumRelatedItems
Write-Debug "Number of related items = " + string(li_NumRelated)
i = 0
do while i < li_NumRelated
    Write-Debug "---- Related Item " + string(i)

    //  Examine the filename (if any)
    Write-Debug "filename: " + loo_Email.GetRelatedFilename(i)
    //  Examine the content-ID (if any)
    Write-Debug "Content-ID: " + loo_Email.GetRelatedContentID(i)
    //  Examine the content-type
    Write-Debug "Content-Type: " + loo_Email.GetRelatedContentType(i)
    //  Examine the content-location (if any)
    Write-Debug "Content-Location" + loo_Email.GetRelatedContentLocation(i)

    i = i + 1
loop

//  The email could also have attached messages.
//  An attached message is another email that was attached to this email.
li_NumAttachedMessages = loo_Email.NumAttachedMessages
Write-Debug "Number of attached messages = " + string(li_NumAttachedMessages)
i = 0
do while i < li_NumAttachedMessages
    Write-Debug "---- Attached message " + string(i)

    //  Examine the attached email
    loo_Em = loo_Email.GetAttachedMessage(i)
    Write-Debug "from: " + loo_Em.From
    Write-Debug "subject: " + loo_Em.Subject
    destroy loo_Em
    i = i + 1
loop

//  An email could also be a multipart/report email.
//  This is a DSN (Delivery Status Notification)
//  The NumReports property indicates how many "reports" exist.
li_NumReports = loo_Email.NumReports
i = 0
Write-Debug "Number of reports = " + string(li_NumReports)
i = 0
do while i < li_NumReports
    Write-Debug "---- Report " + string(i)
    //  Get the raw report data...
    Write-Debug loo_Email.GetReport(i)
    i = i + 1
loop

//  If the email is a multipart/report, then the information
//  from the message/delivery-status part of the email can be retrieved:
if loo_Email.IsMultipartReport() = 1 then

    Write-Debug "--- Delivery Status Information:"
    Write-Debug "Status: " + loo_Email.GetDeliveryStatusInfo("Status")
    Write-Debug "Action: " + loo_Email.GetDeliveryStatusInfo("Action")
    Write-Debug "Reporting-MTA: " + loo_Email.GetDeliveryStatusInfo("Reporting-MTA")

    loo_Sa = loo_Email.GetDsnFinalRecipients()
    li_NumFinalRecipients = loo_Sa.Count
    i = 0
    do while i < li_NumFinalRecipients
        Write-Debug "final recipient: " + loo_Sa.GetString(i)
        i = i + 1
    loop
    destroy loo_Sa
end if



destroy loo_Mime
destroy loo_Email

 

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