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

POP3 Fetch Mime Source of Email by UIDL

Demonstrates how to fetch the MIME source of a single email by UIDL.

Chilkat Lua Downloads

Lua

    -- 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

    --  Download each email as MIME.
    local bdMime = chilkat.newBinData{}

    local count = stUidls:Count()
    local i = 0
    while i < count do
        success = mailman:FetchMimeBd(stUidls:StringAt(i),bdMime)
        if success == false then
            print(mailman:LastErrorText())

        end

        --  Do whatever is needed with the MIME contained in bdMime.

        i = i + 1
    end