DataFlex Requires Chilkat v11.0.0+
DataFlex
Choose the character set for an HTML email
See more Email Object Examples
Read a UTF-8 HTML file as Unicode, then set the charset Chilkat will use when writing the MIME text. The HTML file’s input encoding and the message’s output charset are separate choices. UTF-8 can represent names from multiple writing systems.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoEmail
Handle hoHtml
String sTemp1
Move False To iSuccess
// Assumes Chilkat is unlocked. See Global Unlock Sample.
Get Create (RefClass(cComChilkatEmail)) To hoEmail
If (Not(IsComObjectCreated(hoEmail))) Begin
Send CreateComObject of hoEmail
End
Set ComFrom Of hoEmail To "Workshop team <events@example.com>"
Get ComAddTo Of hoEmail "Alex Rivera" "alex@example.net" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Set ComSubject Of hoEmail To "Workshop registration"
Get Create (RefClass(cComChilkatStringBuilder)) To hoHtml
If (Not(IsComObjectCreated(hoHtml))) Begin
Send CreateComObject of hoHtml
End
Get ComLoadFile Of hoHtml "newsletter.html" "utf-8" To iSuccess
If (iSuccess <> True) Begin
Showln "Failed: html.LoadFile."
Procedure_Return
End
Set ComCharset Of hoEmail To "utf-8"
Get ComGetAsString Of hoHtml To sTemp1
Send ComSetHtmlBody To hoEmail sTemp1
Get ComSaveEml Of hoEmail "newsletter.eml" To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoEmail To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Saved newsletter.eml."
End_Procedure