Sample code for 30+ languages & platforms
Tcl

Check Whether an Email Has an HTML Body

See more Email Object Examples

Demonstrates the Chilkat Email.HasHtmlBody method, which returns true only when a text/html body is present in the current email object. This example sets an HTML body and confirms its presence.

Background: Because a message may contain a plain-text body, an HTML body, both, or neither, it is good practice to test before extracting. HasHtmlBody lets you decide whether to call GetHtmlBody or fall back to GetPlainTextBody — avoiding surprises when a sender provides only one representation.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

#  Demonstrates the HasHtmlBody method, which returns true only when a text/html body is
#  present in the current email object.

set email [new_CkEmail]

CkEmail_put_Subject $email "HasHtmlBody example"

CkEmail_SetHtmlBody $email "<html><body><b>Hello in HTML.</b></body></html>"

if {[CkEmail_HasHtmlBody $email] == 1} then {
    puts "The email has an HTML body."
} else {
    puts "The email does not have an HTML body."
}


delete_CkEmail $email