Sample code for 30+ languages & platforms
Tcl

Get JSON Details from the Last Operation

See more MIME Examples

Demonstrates GetLastJsonData, which copies structured details from the most recent operation into a JsonObject when such details are available. Many operations produce no JSON data, in which case the object is empty or minimal.

The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.

Tip: Code to parse the returned JSON can be generated with Chilkat's online tool at https://tools.chilkat.io/jsonParse.

Background. Some Chilkat operations expose extra diagnostic or result information as JSON. GetLastJsonData provides access to that information after the operation completes.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set mime [new_CkMime]

set success [CkMime_LoadMimeFile $mime "qa_data/encrypted.eml"]
if {$success == 0} then {
    puts [CkMime_lastErrorText $mime]
    delete_CkMime $mime
    exit
}

#  Some operations produce structured JSON details.  After an operation, copy those details into a
#  JsonObject with GetLastJsonData.  Many methods produce no JSON, in which case the object is
#  little or empty.
set pfxPassword "myPfxPassword"
set success [CkMime_AddPfxSourceFile $mime "qa_data/recipient.pfx" $pfxPassword]
if {$success == 0} then {
    puts [CkMime_lastErrorText $mime]
    delete_CkMime $mime
    exit
}

set success [CkMime_Decrypt $mime]
if {$success == 0} then {
    puts [CkMime_lastErrorText $mime]
    delete_CkMime $mime
    exit
}

set json [new_CkJsonObject]

CkMime_GetLastJsonData $mime $json

CkJsonObject_put_EmitCompact $json 0
set jsonStr [CkJsonObject_emit $json]
puts "$jsonStr"

delete_CkMime $mime
delete_CkJsonObject $json