Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
llSuccess = .F.

//  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.

loImap = createobject("CkImap")

loImap.Ssl = .T.
loImap.Port = 993

llSuccess = loImap.Connect("imap.example.com")
if (llSuccess = .F.) then
    ? loImap.LastErrorText
    release loImap
    return
endif

llSuccess = loImap.Login("user@example.com","myPassword")
if (llSuccess = .F.) then
    ? loImap.LastErrorText
    release loImap
    return
endif

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

? "Session log cleared."

llSuccess = loImap.Disconnect()
if (llSuccess = .F.) then
    ? loImap.LastErrorText
    release loImap
    return
endif



release loImap