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

Extract Files from MIME

See more MIME Examples

Extract files from a MIME message.

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 mime = CkoMime()!

    //  Load a MIME document from a file:
    //  (.mht and .eml files contain MIME).
    success = mime.loadFile(path: "mst.mht")
    if success == false {
        print("\(mime.lastErrorText!)")
        return
    }

    let st = CkoStringTable()!
    success = mime.parts(toFiles: "/temp/mimeParts", st: st)
    if success == false {
        print("\(mime.lastErrorText!)")
        return
    }

    var n: Int = st.count.intValue

    //  Display the paths of the files created:
    var i: Int = 0
    while i < n {
        print("\(st.string(at: i)!)")
        i = i + 1
    }


}