Sample code for 30+ languages & platforms
Tcl

MIME Content Part Descriptor Properties

See more MIME Examples

Demonstrates the properties that describe an individual MIME content part: Charset (the charset parameter of Content-Type), Encoding (the Content-Transfer-Encoding), Disposition (the Content-Disposition value), Filename (the filename parameter of Content-Disposition), and Name (the name parameter of Content-Type). Each is set and then read back, and the effect is visible in the serialized MIME header.

Background. These properties operate on the current MIME entity's header fields. Filename and Name are receiver-facing labels, not local filesystem paths, and Charset is meaningful for text parts.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

set mime [new_CkMime]

set success [CkMime_SetBodyFromPlainText $mime "The quick brown fox."]
if {$success == 0} then {
    puts [CkMime_lastErrorText $mime]
    delete_CkMime $mime
    exit
}

#  Charset is the charset parameter of the Content-Type header field (meaningful for text parts).
CkMime_put_Charset $mime "utf-8"

#  Encoding is the Content-Transfer-Encoding for this part.
CkMime_put_Encoding $mime "quoted-printable"

#  Disposition, Filename, and Name describe how a receiver should present the part.
#  Filename is the filename parameter of Content-Disposition; Name is the name parameter of
#  Content-Type.  Both are receiver-facing names, not local filesystem paths.
CkMime_put_Disposition $mime "attachment"
CkMime_put_Filename $mime "note.txt"
CkMime_put_Name $mime "note.txt"

#  Read the descriptors back.
puts "Charset = [CkMime_charset $mime]"
puts "Encoding = [CkMime_encoding $mime]"
puts "Disposition = [CkMime_disposition $mime]"
puts "Filename = [CkMime_filename $mime]"
puts "Name = [CkMime_name $mime]"

#  The descriptors appear in the serialized MIME header.
set mimeStr [CkMime_getMime $mime]
if {[CkMime_get_LastMethodSuccess $mime] == 0} then {
    puts [CkMime_lastErrorText $mime]
    delete_CkMime $mime
    exit
}

puts "$mimeStr"

delete_CkMime $mime