Lua
Lua
Iterate Email Headers
Demonstrates how to iterate over the email header fields.Chilkat Lua Downloads
local chilkat = require("chilkat")
local email = chilkat.Email.new()
-- 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...
local success = email:load_eml("testReceivedHdrs.eml")
if not success then
print(email.last_error_text)
return
end
-- How many header fields?
local n = email.num_header_fields
if n > 0 then
-- Display the name and value of each header:
local name = ""
local value = ""
for i = 0, n - 1 do
name = email:get_header_field_name(i)
value = email:get_header_field_value(i)
print(i)
print(name)
print(value)
end
end