Sample code for 30+ languages & platforms
PowerBuilder Requires Chilkat v11.0.0+

Inspect the MIME structure and contents of an EML file

See more Email Object Examples

Open the complete EML in Mime for a tree view and in Email for application-level collections. An HTML logo, downloadable file, attached message, and delivery report are counted separately. Try the complex workshop draft.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
long li_Success
oleobject loo_Email
oleobject loo_Mime
long i

li_Success = 0

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
    destroy loo_Email
    MessageBox("Error","Connecting to COM object failed")
    return
end if
li_Success = loo_Email.LoadEml("workshop.eml")
if li_Success <> 1 then
    Write-Debug loo_Email.LastErrorText
    destroy loo_Email
    return
end if

loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")

li_Success = loo_Mime.LoadMimeFile("workshop.eml")
if li_Success <> 1 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Email
    destroy loo_Mime
    return
end if

Write-Debug loo_Mime.GetStructure("text")
Write-Debug "Subject: " + loo_Email.Subject
Write-Debug "Files: " + string(loo_Email.NumAttachments) + "  Related items: " + string(loo_Email.NumRelatedItems)
Write-Debug "Attached messages: " + string(loo_Email.NumAttachedMessages) + "  Reports: " + string(loo_Email.NumReports)
i = 0
do while (i < loo_Email.NumAttachments)
    Write-Debug loo_Email.GetAttachmentFilename(i) + "  " + loo_Email.GetAttachmentContentType(i) + "  " + string(loo_Email.GetAttachmentSize(i)) + " bytes"
    i = i + 1
loop
i = 0
do while (i < loo_Email.NumRelatedItems)
    Write-Debug "Related: " + loo_Email.GetRelatedFilename(i) + "  " + loo_Email.GetRelatedContentType(i)
    i = i + 1
loop


destroy loo_Email
destroy loo_Mime