Tcl
Tcl
List IMAP Mailboxes with Reference
Demonstrates how to list all sub-mailboxes within a specified context. In this case, we list all mailboxes under "INBOX.vendors".Chilkat Tcl Downloads
load ./chilkat.dll
set success 0
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set imap [new_CkImap]
# Connect to an IMAP server.
# Use TLS
CkImap_put_Ssl $imap 1
CkImap_put_Port $imap 993
set success [CkImap_Connect $imap "imap.example.com"]
if {$success == 0} then {
puts [CkImap_lastErrorText $imap]
delete_CkImap $imap
exit
}
# Login
set success [CkImap_Login $imap "admin@chilkatsoft.com" "myPassword"]
if {$success == 0} then {
puts [CkImap_lastErrorText $imap]
delete_CkImap $imap
exit
}
# Get the list of mailboxes.
set refName ""
set wildcardedMailbox "*"
set subscribed 0
set mboxes [new_CkMailboxes]
set success [CkImap_MbxList $imap $subscribed $refName $wildcardedMailbox $mboxes]
if {$success == 0} then {
puts [CkImap_lastErrorText $imap]
delete_CkImap $imap
delete_CkMailboxes $mboxes
exit
}
set i 0
while {$i < [CkMailboxes_get_Count $mboxes]} {
puts [CkMailboxes_getName $mboxes $i]
set i [expr $i + 1]
}
# Sample output looks like this:
# INBOX.vendors.shareit
# INBOX.vendors.paypal
# INBOX.vendors.dell
# INBOX.vendors.inMotion
# INBOX.vendors.myhosting
# INBOX.vendors.peer1
# Disconnect from the IMAP server.
set success [CkImap_Disconnect $imap]
delete_CkImap $imap
delete_CkMailboxes $mboxes