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
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
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) Fetch Full Email Given Email Header

When email headers are fetched using UIDs (not sequence numbers), then the resultant email object (containing only the header) will include auto-generated ckx-imap-* header fields to record information about the uid, attachments, etc. The IMAP UID of the email will be available in the "ckx-imap-uid" header. There will also be a "ckx-imap-isUid" header field having the value "YES" or "NO". If the email header was downloaded by UID, then "ckx-imap-isUID" will contain the value "YES" and the value of the "ckx-imap-uid" header field is the IMAP UID. If the "ckx-imap-isUID" header has a value of "NO", then the "ckx-imap-uid" header field represents the sequence number. (Sequence numbers of emails on the server can change over time, depending on whether emails are deleted. UIDs must be used to ensure that the correct full email is downloaded.)

The Chilkat Email object provides a GetImapUid method to return the UID from the ckx-imap-uid header. This can then be used to download the full email using the FetchSingle method. Assuming the UID is known, download a single email by UID from an IMAP mail server.

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 "imap.someMailServer.com"]
if {[expr $success != 1]} then {
    puts [CkImap_lastErrorText $imap]
    delete_CkImap $imap
    exit
}

#  Login
set success [CkImap_Login $imap "***" "***"]
if {[expr $success != 1]} then {
    puts [CkImap_lastErrorText $imap]
    delete_CkImap $imap
    exit
}

#  Select an IMAP mailbox
set success [CkImap_SelectMailbox $imap "Inbox"]
if {[expr $success != 1]} then {
    puts [CkImap_lastErrorText $imap]
    delete_CkImap $imap
    exit
}

# emailHeader is a CkEmail

# emailFull is a CkEmail

set uid 2014
set isUid 1

#  Fetch only the email header
set emailHeader [CkImap_FetchSingleHeader $imap $uid $isUid]
if {![string equal $emailHeader "NULL"]} then {

    #  Now fetch the full email
    set uidFromCkxHeader [CkEmail_GetImapUid $emailHeader]
    if {[expr $uidFromCkxHeader < 0]} then {
        #  Failed.
        delete_CkEmail $emailHeader

        puts "No ckx-imap-uid header was found."
        delete_CkImap $imap
        exit
    }

    set emailFull [CkImap_FetchSingle $imap $uidFromCkxHeader 1]
    if {![string equal $emailFull "NULL"]} then {

        #  OK, we have the full email, do whatever we want...

        delete_CkEmail $emailFull

    }

    delete_CkEmail $emailHeader

}

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

delete_CkImap $imap

 

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