DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoEmail
Boolean bTemp1
// Demonstrates the HasHtmlBody method, which returns true only when a text/html body is
// present in the current email object.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "HasHtmlBody example"
Send ComSetHtmlBody To hoEmail "<html><body><b>Hello in HTML.</b></body></html>"
Get ComHasHtmlBody Of hoEmail To bTemp1
If (bTemp1 = True) Begin
Showln "The email has an HTML body."
End
Else Begin
Showln "The email does not have an HTML body."
End
End_Procedure