Sample code for 30+ languages & platforms
Lua Requires Chilkat v11.0.0+

Retrieve UIDL's from POP3 Server

Retrieve a list of UIDLs from a POP3 server. UIDLs are unique identifiers, 1 to 70 characters long, composed of characters ranging from 0x21 to 0x7E. These identifiers uniquely distinguish messages within a mailbox and remain consistent across sessions.

Chilkat Lua Downloads

Lua
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

-- Download each email by UIDL.
local email = chilkat.Email.new()

local count = stUidls.count
local i = 0
while i < count do
    -- Download the full email.
    local uidl = stUidls:string_at(i)
    success = mailman:fetch_by_uidl(uidl, false, 0, email)
    if not success then
        print(mailman.last_error_text)
        return
    end

    print(i)
    print("UIDL: " .. uidl)
    print("From: " .. email.from)
    print("Subject: " .. email.subject)

    i = i + 1
end

mailman:pop3_end_session()