Sample code for 30+ languages & platforms
Tcl Requires Chilkat v11.0.0+

Choose the character set for an HTML email

See more Email Object Examples

Read a UTF-8 HTML file as Unicode, then set the charset Chilkat will use when writing the MIME text. The HTML file’s input encoding and the message’s output charset are separate choices. UTF-8 can represent names from multiple writing systems.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

#  Assumes Chilkat is unlocked. See Global Unlock Sample.

set email [new_CkEmail]

CkEmail_put_From $email "Workshop team <events@example.com>"
set success [CkEmail_AddTo $email "Alex Rivera" "alex@example.net"]
if {$success != 1} then {
    puts [CkEmail_lastErrorText $email]
    delete_CkEmail $email
    exit
}

CkEmail_put_Subject $email "Workshop registration"
set html [new_CkStringBuilder]

set success [CkStringBuilder_LoadFile $html "newsletter.html" "utf-8"]
if {$success != 1} then {
    puts "Failed: html.LoadFile."
    delete_CkEmail $email
    delete_CkStringBuilder $html
    exit
}

CkEmail_put_Charset $email "utf-8"
CkEmail_SetHtmlBody $email [CkStringBuilder_getAsString $html]

set success [CkEmail_SaveEml $email "newsletter.eml"]
if {$success != 1} then {
    puts [CkEmail_lastErrorText $email]
    delete_CkEmail $email
    delete_CkStringBuilder $html
    exit
}

puts "Saved newsletter.eml."

delete_CkEmail $email
delete_CkStringBuilder $html