Sample code for 30+ languages & platforms
Swift

POP3 Fetch Mime Source of Email by UIDL

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

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let mailman = CkoMailMan()!

    mailman.mailHost = "pop.example.com"

    mailman.popUsername = "myLogin"
    mailman.popPassword = "myPassword"

    mailman.mailPort = 995
    mailman.popSsl = true

    let stUidls = CkoStringTable()!
    success = mailman.fetchUidls(uidls: stUidls)
    if success == false {
        print("\(mailman.lastErrorText!)")
        return
    }

    // Download each email as MIME.
    let bdMime = CkoBinData()!

    var count: Int = stUidls.count.intValue
    var i: Int = 0
    while i < count {
        success = mailman.fetchMimeBd(uidl: stUidls.string(at: i), mimeData: bdMime)
        if success == false {
            print("\(mailman.lastErrorText!)")
            return
        }

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

        i = i + 1
    }


}