DataFlex
DataFlex
Set the HTML Body of an Email
See more Email Object Examples
Demonstrates the Chilkat Email.SetHtmlBody method, which creates or replaces the text/html body of an email. It does not automatically create a plain-text alternative. This example sets an HTML body and confirms its presence.
Background:
SetHtmlBody gives you explicit control over the HTML representation, unlike the general Body property which guesses the body type from the content. For a well-formed message you would typically also add a plain-text alternative (with AddPlainTextAlternativeBody) so text-only clients, accessibility tools, and spam filters have a fallback to read.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoEmail
String sTemp1
Boolean bTemp1
// Demonstrates the SetHtmlBody method, which creates or replaces the text/html body of an
// email. It does not automatically create a plain-text alternative.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComSubject Of hoEmail To "Set HTML body"
// Set the HTML body.
Send ComSetHtmlBody To hoEmail "<html><body><h1>Welcome</h1><p>This is an HTML email.</p></body></html>"
Get ComHasHtmlBody Of hoEmail To bTemp1
Showln "HasHtmlBody: " bTemp1
Get ComGetMime Of hoEmail To sTemp1
Showln sTemp1
End_Procedure