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
-- In the following call to loadlib, change the path (./chilkat.dll) to the relative or absolute directory where the chilkat.dll, chilkat.so, or chilkat.dylib is located.
chilkat = assert(package.loadlib("./chilkat.dll", "luaopen_chilkat"))()
print(chilkat._VERSION)
local success = false
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local mailman = chilkat.newMailMan{}
mailman:setMailHost("pop.example.com")
mailman:setPopUsername("myLogin")
mailman:setPopPassword("myPassword")
mailman:setMailPort(995)
mailman:setPopSsl(true)
local stUidls = chilkat.newStringTable{}
success = mailman:FetchUidls(stUidls)
if success == false then
print(mailman:LastErrorText())
end
local email = chilkat.newEmail{}
local count = stUidls:Count()
local i = 0
while i < count do
-- Download the full email.
success = mailman:FetchByUidl(stUidls:StringAt(i),false,0,email)
if success == false then
print(mailman:LastErrorText())
end
print(i)
print("From: ", email:From())
print("Subject: ", email:Subject())
i = i + 1
end
mailman:Pop3EndSession()