PowerBuilder Requires Chilkat v11.0.0+
PowerBuilder
Read an attached email
See more Email Object Examples
Open forward-as-attachment.eml from the forwarding example. Read the cover note’s subject, then open each attached message and inspect its own headers and attachment count. This works even when the outer message has no ordinary files.
Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Wrapper
oleobject loo_Nested
long i
li_Success = 0
// Assumes Chilkat is unlocked. See Global Unlock Sample.
loo_Wrapper = create oleobject
li_rc = loo_Wrapper.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
destroy loo_Wrapper
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Wrapper.LoadEml("forward-as-attachment.eml")
if li_Success <> 1 then
Write-Debug loo_Wrapper.LastErrorText
destroy loo_Wrapper
return
end if
Write-Debug "Cover note: " + loo_Wrapper.Subject
if loo_Wrapper.NumAttachedMessages = 0 then
Write-Debug "No attached messages."
destroy loo_Wrapper
return
end if
loo_Nested = create oleobject
li_rc = loo_Nested.ConnectToNewObject("Chilkat.Email")
i = 0
do while (i < loo_Wrapper.NumAttachedMessages)
li_Success = loo_Wrapper.GetAttachedEmail(i,loo_Nested)
if li_Success <> 1 then
Write-Debug loo_Wrapper.LastErrorText
destroy loo_Wrapper
destroy loo_Nested
return
end if
Write-Debug "Original author: " + loo_Nested.From
Write-Debug "Original subject: " + loo_Nested.Subject
Write-Debug "Files on the original: " + string(loo_Nested.NumAttachments)
i = i + 1
loop
destroy loo_Wrapper
destroy loo_Nested