Sample code for 30+ languages & platforms
Tcl

Serialize MIME to a StringBuilder

See more MIME Examples

Demonstrates the Chilkat Mime.GetMimeSb method, which serializes the complete MIME entity and appends it to a StringBuilder. The only argument is the StringBuilder; existing content is preserved.

Background: Serializing into a StringBuilder avoids creating a new string and is convenient when you are accumulating output or building a larger document. Because it appends, you can assemble several pieces in one buffer. As with GetMime, use the BinData form for content with arbitrary binary bytes.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

#  Demonstrates the Mime.GetMimeSb method, which serializes the complete MIME entity and appends
#  it to a StringBuilder.  The only argument is the StringBuilder.

set mime [new_CkMime]

set success [CkMime_SetBodyFromPlainText $mime "Hello, this is the message body."]
if {$success == 0} then {
    puts [CkMime_lastErrorText $mime]
    delete_CkMime $mime
    exit
}

#  Append the serialized MIME to a StringBuilder.  Existing content is preserved.
set sb [new_CkStringBuilder]

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

puts [CkStringBuilder_getAsString $sb]

delete_CkMime $mime
delete_CkStringBuilder $sb