PowerBuilder
PowerBuilder
Iterate Email Headers
Demonstrates how to iterate over the email header fields.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Email
integer n
integer i
string ls_Name
string ls_Value
li_Success = 0
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
// First, load an email from a file.
// Note: an email object may be loaded from a file, or
// downloaded directly from a POP3 or IMAP server...
li_Success = loo_Email.LoadEml("testReceivedHdrs.eml")
if li_Success <> 1 then
Write-Debug loo_Email.LastErrorText
destroy loo_Email
return
end if
// How many header fields?
n = loo_Email.NumHeaderFields
if n > 0 then
// Display the name and value of each header:
for i = 0 to n - 1
ls_Name = loo_Email.GetHeaderFieldName(i)
ls_Value = loo_Email.GetHeaderFieldValue(i)
Write-Debug string(i)
Write-Debug ls_Name
Write-Debug ls_Value
next
end if
destroy loo_Email