(Swift) POP3 Fetch Mime Source of Email by UIDL
Demonstrates how to fetch the MIME source of a single email by UIDL. Note: This example requires Chilkat v11.0.0 or greater.
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(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(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
}
}
|