Sample code for 30+ languages & platforms
Swift

Clear the IMAP Session Log

See more IMAP Examples

Demonstrates the Chilkat Imap.ClearSessionLog method, which clears the in-memory text returned by the SessionLog property. Session logging remains enabled or disabled according to the KeepSessionLog property. This example connects, logs in, and clears the log.

Background: When session logging is enabled, the SessionLog accumulates the raw IMAP command/response dialog — the first thing to inspect when diagnosing a failure. Over a long-lived session that log grows continuously; ClearSessionLog resets it so you can capture just the exchange for the next operation of interest, rather than sifting through the entire history.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    //  Demonstrates the Imap.ClearSessionLog method, which clears the in-memory text returned by
    //  the SessionLog property.  Session logging remains enabled or disabled according to the
    //  KeepSessionLog property.

    let imap = CkoImap()!

    imap.ssl = true
    imap.port = 993

    success = imap.connect(hostname: "imap.example.com")
    if success == false {
        print("\(imap.lastErrorText!)")
        return
    }

    success = imap.login(login: "user@example.com", password: "myPassword")
    if success == false {
        print("\(imap.lastErrorText!)")
        return
    }

    //  Clear the session log (for example, before the next operation you want to capture).
    imap.clearSessionLog()

    print("Session log cleared.")

    success = imap.disconnect()
    if success == false {
        print("\(imap.lastErrorText!)")
        return
    }


}