Sample code for 30+ languages & platforms
Tcl

Load MIME from a String

See more MIME Examples

Demonstrates the Chilkat Mime.LoadMime method, which parses complete MIME text and replaces the current object's headers, body, and multipart tree. The only argument is the MIME string.

Background: MIME is the structure behind email messages and many other content containers — a set of headers, a blank line, then a body that may itself be a tree of nested parts. Loading parses that text into an object you can then inspect and modify part by part. A successful load fully replaces whatever the object held before, and Chilkat is tolerant of common real-world formatting quirks. When the content may contain raw 8-bit or NUL bytes, prefer LoadMimeBd so nothing is forced through a text string.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

#  Demonstrates the Mime.LoadMime method, which parses complete MIME text and replaces the current
#  object's headers, body, and multipart tree.  The only argument is the MIME string.

set mime [new_CkMime]

#  The complete MIME text (headers, a blank line, then the body).
set mimeText "Content-Type: text/plain\r\n\r\nThis is the body.\r\n"

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

puts "Content-Type: [CkMime_contentType $mime]"

delete_CkMime $mime