Sample code for 30+ languages & platforms
PowerBuilder

Parsing a Multipart/Digest Email

See more Email Object Examples

This example demonstrates how to parse a multipart/digest email. An email parsed by this sample could have a MIME structure as follows:
multipart/mixed
    text/plain
    text/plain
    multipart/digest
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
    text/plain

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
string ls_EmlPath
oleobject loo_Email
integer li_NumDigests
oleobject loo_EDigest
integer i
string m

li_Success = 0

ls_EmlPath = "qa_data/eml/multipart_digest.eml"

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

// For this example, we'll load the email from a .eml.
// The email could alternatively be loaded as a result of downloading from an IMAP or POP3 server..

li_Success = loo_Email.LoadEml(ls_EmlPath)
if li_Success = 0 then
    Write-Debug loo_Email.LastErrorText
    destroy loo_Email
    return
end if

li_NumDigests = loo_Email.NumDigests
Write-Debug "num digests = " + string(li_NumDigests)

loo_EDigest = create oleobject
li_rc = loo_EDigest.ConnectToNewObject("Chilkat.Email")

i = 0
do while i < li_NumDigests
    loo_Email.GetDigestEmail(i,loo_EDigest)
    Write-Debug string(i) + ":" + loo_EDigest.FromAddress + ", " + loo_EDigest.Subject
    m = loo_EDigest.GetHeaderField("Message")
    if loo_EDigest.LastMethodSuccess = 1 then
        Write-Debug "    Message = " + m
    end if

    i = i + 1
loop


destroy loo_Email
destroy loo_EDigest