Sample code for 30+ languages & platforms
PureBasic

IMAP Session Logging

Demonstrates how to use session logging with IMAP.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkImap.pb"

Procedure ChilkatExample()

    success.i = 0

    ; This example assumes the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.

    imap.i = CkImap::ckCreate()
    If imap.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ; Set the KeepSessionLog property to enable IMAP session logging
    CkImap::setCkKeepSessionLog(imap, 1)

    ; Connect to an IMAP server.
    ; Use TLS
    CkImap::setCkSsl(imap, 1)
    CkImap::setCkPort(imap, 993)
    success = CkImap::ckConnect(imap,"imap.example.com")
    If success <> 1
        Debug CkImap::ckLastErrorText(imap)
        CkImap::ckDispose(imap)
        ProcedureReturn
    EndIf

    ; Login
    success = CkImap::ckLogin(imap,"mylogin","mypassword")
    If success <> 1
        Debug CkImap::ckLastErrorText(imap)
        CkImap::ckDispose(imap)
        ProcedureReturn
    EndIf

    ; Select an IMAP mailbox
    success = CkImap::ckSelectMailbox(imap,"Inbox")
    If success <> 1
        Debug CkImap::ckLastErrorText(imap)
        CkImap::ckDispose(imap)
        ProcedureReturn
    EndIf

    ; We're not really doing anything in this example
    ; other than to show how to examine the IMAP component's session log...

    ; Disconnect from the IMAP server.
    success = CkImap::ckDisconnect(imap)

    ; Display the session log...
    Debug CkImap::ckSessionLog(imap)


    CkImap::ckDispose(imap)


    ProcedureReturn
EndProcedure