PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
oleobject loo_Email
// Demonstrates the HasHtmlBody method, which returns true only when a text/html 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 = "HasHtmlBody example"
loo_Email.SetHtmlBody("<html><body><b>Hello in HTML.</b></body></html>")
if loo_Email.HasHtmlBody() = 1 then
Write-Debug "The email has an HTML body."
else
Write-Debug "The email does not have an HTML body."
end if
destroy loo_Email