Sample code for 30+ languages & platforms
PowerBuilder

Check Whether an Email Has a Plain-Text Body

See more Email Object Examples

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

Background: The plain-text body is the fallback representation used when HTML is unavailable or unwanted — and the form usually preferred for search, indexing, and accessibility. HasPlainTextBody is the counterpart to HasHtmlBody; testing both lets a program handle every combination (text-only, HTML-only, both, or neither) gracefully.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Email

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

loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
    destroy loo_Email
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Email.Subject = "HasPlainTextBody example"

loo_Email.SetTextBody("Hello, this is the plain-text body.","text/plain")

if loo_Email.HasPlainTextBody() = 1 then
    Write-Debug "The email has a plain-text body."
else
    Write-Debug "The email does not have a plain-text body."
end if



destroy loo_Email