Swift
Swift
Fetch the UIDLs of All POP3 Messages
See more POP3 Examples
Demonstrates the Chilkat MailMan.FetchUidls method, which retrieves the UIDLs of the messages currently in the POP3 mailbox and stores them in a StringTable, one entry per message, in the server's current mailbox order. This example lists every UIDL.
Background: The UIDL list is the starting point for incremental mail retrieval. A client keeps a record of the UIDLs it has already downloaded; on each check it fetches the current list, computes the difference, and downloads only the new ones (see
FetchUidlSet). This is how "leave a copy on the server" works without repeatedly re-downloading the same messages.Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
// Demonstrates the MailMan.FetchUidls method, which retrieves the UIDLs of the messages
// currently in the POP3 mailbox and stores them in a StringTable, one entry per message, in
// the server's current mailbox order.
let mailman = CkoMailMan()!
// Configure the POP3 server connection.
mailman.mailHost = "pop.example.com"
mailman.mailPort = 995
mailman.popSsl = true
mailman.popUsername = "user@example.com"
mailman.popPassword = "myPassword"
// Retrieve the UIDLs of all messages in the mailbox.
let uidls = CkoStringTable()!
success = mailman.fetchUidls(uidls: uidls)
if success == false {
print("\(mailman.lastErrorText!)")
return
}
var n: Int = uidls.count.intValue
print("Mailbox contains \(n) messages.")
var i: Int
for i = 0; i <= n - 1; i++ {
print("UIDL \(i): \(uidls.string(at: i)!)")
}
// Note: Explicitly connecting/authenticating is optional. Chilkat MailMan automatically
// connects and authenticates -- using the property settings above -- whenever a server
// operation requires it. Calling the explicit connect/authenticate methods can still be
// helpful to determine whether a failure occurs while connecting or while authenticating.
}