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

Transition from MailMan.GetHeaders to MailMan.FetchRange

Provides instructions for replacing deprecated GetHeaders method calls with FetchRange.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let mailman = CkoMailMan()!

    //  ...
    //  ...

    var numBodyLines: Int = 3
    var fromIndex: Int = 0
    var toIndex: Int = 9

    //  ------------------------------------------------------------------------
    //  The GetHeaders method is deprecated:

    var bundleObj: CkoEmailBundle? = mailman.getHeaders(numBodyLines: numBodyLines, fromIndex: fromIndex, toIndex: toIndex)
    if mailman.lastMethodSuccess == false {
        print("\(mailman.lastErrorText!)")
        return
    }

    //  ...
    //  ...

    bundleObj = nil

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

    var keepOnServer: Bool = true
    var headersOnly: Bool = true

    let bundleOut = CkoEmailBundle()!
    success = mailman.fetchRange(keepOnServer: keepOnServer, headersOnly: headersOnly, numBodyLines: numBodyLines, startIndex: fromIndex, endIndex: toIndex, bundle: bundleOut)
    if success == false {
        print("\(mailman.lastErrorText!)")
        return
    }


}