PowerBuilder
PowerBuilder
Get the Plain-Text Body of an Email
See more Email Object Examples
Demonstrates the Chilkat Email.GetPlainTextBody method, which returns the email body having the text/plain content type. It reads the plain-text representation already present in the email object rather than generating one from HTML. This example sets a plain-text body and reads it back.
Background: The plain-text body is the fallback representation of a message — the version shown when HTML can't or shouldn't be rendered, and the form usually preferred for search, indexing, and accessibility.
GetPlainTextBody targets it specifically; if the message contains only HTML, this returns empty (check with HasPlainTextBody), so a robust extractor falls back to GetHtmlBody when needed.Chilkat PowerBuilder Downloads
integer li_rc
oleobject loo_Email
string ls_Plain
// Demonstrates the GetPlainTextBody method, which returns the email body having the
// text/plain content type. It reads the plain-text representation already present in the
// 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 = "GetPlainTextBody example"
loo_Email.SetTextBody("Hello, this is the plain-text body.","text/plain")
// Retrieve the text/plain body.
ls_Plain = loo_Email.GetPlainTextBody()
Write-Debug ls_Plain
destroy loo_Email