Lua Requires Chilkat v11.0.0+
Lua
POP3 Fetch a Single Email by UIDL
Demonstrates how to fetch a single email by UIDL.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local mailman = chilkat.MailMan.new()
mailman.mail_host = "pop.example.com"
mailman.pop_username = "myLogin"
mailman.pop_password = "myPassword"
mailman.mail_port = 995
mailman.pop_ssl = true
local stUidls = chilkat.StringTable.new()
local success = mailman:fetch_uidls(stUidls)
if not success then
print(mailman.last_error_text)
return
end
local email = chilkat.Email.new()
local count = stUidls.count
local i = 0
while i < count do
-- Download the full email.
success = mailman:fetch_by_uidl(stUidls:string_at(i), false, 0, email)
if not success then
print(mailman.last_error_text)
return
end
print(i)
print("From: " .. email.from)
print("Subject: " .. email.subject)
i = i + 1
end
mailman:pop3_end_session()