Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Tcl Examples

ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
FileAccess
Firebase
GMail REST API
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Sheets
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)

Java KeyStore (JKS)
Jira
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Shopify
Socket/SSL/TLS
Spider
Stream
Stripe
SugarCRM
Tar Archive
Twitter
Upload
VoiceBase
Walmart
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(Tcl) List IMAP Mailboxes

List the mailboxes available within an IMAP account.

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

set imap [new_CkImap]

#  Anything unlocks the component and begins a fully-functional 30-day trial.
set success [CkImap_UnlockComponent $imap "Anything for 30-day trial"]
if {[expr $success != 1]} then {
    puts [CkImap_lastErrorText $imap]
    delete_CkImap $imap
    exit
}

#  Connect to an IMAP server.
#  Use TLS
CkImap_put_Ssl $imap 1
CkImap_put_Port $imap 993
set success [CkImap_Connect $imap "MY-IMAP-DOMAIN"]
if {[expr $success != 1]} then {
    puts [CkImap_lastErrorText $imap]
    delete_CkImap $imap
    exit
}

#  Login
set success [CkImap_Login $imap "MY-IMAP-LOGIN" "MY-IMAP-PASSWORD"]
if {[expr $success != 1]} then {
    puts [CkImap_lastErrorText $imap]
    delete_CkImap $imap
    exit
}

#  The ListMailboxes method returns a Mailboxes object
#  that contains the collection of mailboxes.
#  It accepts two arguments: a refName and a wildcardedMailbox.

set refName ""
#  refName is usually set to an empty string.
#  A non-empty reference name argument is the name of a mailbox or a level of
#  mailbox hierarchy, and indicates the context in which the mailbox
#  name is interpreted.

#  Select all mailboxes matching this pattern:
set wildcardedMailbox "*"

# mboxes is a CkMailboxes
set mboxes [CkImap_ListMailboxes $imap $refName $wildcardedMailbox]
if {[string equal $mboxes "NULL"]} then {
    puts [CkImap_lastErrorText $imap]
    delete_CkImap $imap
    exit
}

for {set i 0} {$i <= [expr [CkMailboxes_get_Count $mboxes] - 1]} {incr i} {
    puts [CkMailboxes_getName $mboxes $i]
}

#  Sample output looks like this:
#  INBOX.vendors.shareit
#  INBOX.oldSupport
#  INBOX.vendors.paypal
#  INBOX.sales
#  INBOX.lists
#  INBOX.Drafts
#  INBOX.vendors.dell
#  INBOX.Trash
#  INBOX.invoiceRequests
#  INBOX.purchases
#  INBOX.vendors.inMotion
#  INBOX.oldEmail
#  INBOX.vendors
#  INBOX.lists.python
#  INBOX.vendors.myhosting
#  INBOX.Templates
#  INBOX.friends
#  INBOX.bounceSamples
#  INBOX.lists.ruby
#  INBOX.vendors.peer1
#  INBOX.Sent
#  INBOX.Junk
#  INBOX

#  Disconnect from the IMAP server.
set success [CkImap_Disconnect $imap]

delete_CkMailboxes $mboxes


delete_CkImap $imap

 

© 2000-2016 Chilkat Software, Inc. All Rights Reserved.