Sample code for 30+ languages & platforms
Swift

Transition from Imap.CheckForNewEmail to Imap.QueryMbx

Provides instructions for replacing deprecated CheckForNewEmail method calls with QueryMbx.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let imap = CkoImap()!

    // ...
    // ...

    // ------------------------------------------------------------------------
    // The CheckForNewEmail method is deprecated:

    var msgSetObj: CkoMessageSet? = imap.checkForNewEmail()
    if imap.lastMethodSuccess == false {
        print("\(imap.lastErrorText!)")
        return
    }

    // ...
    // ...

    msgSetObj = nil

    // ------------------------------------------------------------------------
    // Do the equivalent using QueryMbx.
    // Your application creates a new, empty MessageSet object which is passed 
    // in the last argument and filled upon success.

    var criteria: String? = "new-email"
    var bUid: Bool = true

    let msgSet = CkoMessageSet()!
    success = imap.queryMbx(criteria: criteria, bUid: bUid, msgSet: msgSet)
    if success == false {
        print("\(imap.lastErrorText!)")
        return
    }


}