PureBasic Requires Chilkat v11.0.0+
PureBasic
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 PureBasic Downloads
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkEmail.pb"
Procedure ChilkatExample()
success.i = 0
; Assumes Chilkat is unlocked. See Global Unlock Sample.
email.i = CkEmail::ckCreate()
If email.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkEmail::setCkFrom(email, "Workshop team <events@example.com>")
success = CkEmail::ckAddTo(email,"Alex Rivera","alex@example.net")
If success <> 1
Debug CkEmail::ckLastErrorText(email)
CkEmail::ckDispose(email)
ProcedureReturn
EndIf
CkEmail::setCkSubject(email, "Workshop registration")
html.i = CkStringBuilder::ckCreate()
If html.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkStringBuilder::ckLoadFile(html,"newsletter.html","utf-8")
If success <> 1
Debug "Failed: html.LoadFile."
CkEmail::ckDispose(email)
CkStringBuilder::ckDispose(html)
ProcedureReturn
EndIf
CkEmail::setCkCharset(email, "utf-8")
CkEmail::ckSetHtmlBody(email,CkStringBuilder::ckGetAsString(html))
success = CkEmail::ckSaveEml(email,"newsletter.eml")
If success <> 1
Debug CkEmail::ckLastErrorText(email)
CkEmail::ckDispose(email)
CkStringBuilder::ckDispose(html)
ProcedureReturn
EndIf
Debug "Saved newsletter.eml."
CkEmail::ckDispose(email)
CkStringBuilder::ckDispose(html)
ProcedureReturn
EndProcedure