PowerBuilder Requires Chilkat v11.0.0+
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Email
oleobject loo_Html
li_Success = 0
// Assumes Chilkat is unlocked. See Global Unlock Sample.
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.From = "Workshop team <events@example.com>"
li_Success = loo_Email.AddTo("Alex Rivera","alex@example.net")
if li_Success <> 1 then
Write-Debug loo_Email.LastErrorText
destroy loo_Email
return
end if
loo_Email.Subject = "Workshop registration"
loo_Html = create oleobject
li_rc = loo_Html.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_Html.LoadFile("newsletter.html","utf-8")
if li_Success <> 1 then
Write-Debug "Failed: html.LoadFile."
destroy loo_Email
destroy loo_Html
return
end if
loo_Email.Charset = "utf-8"
loo_Email.SetHtmlBody(loo_Html.GetAsString())
li_Success = loo_Email.SaveEml("newsletter.eml")
if li_Success <> 1 then
Write-Debug loo_Email.LastErrorText
destroy loo_Email
destroy loo_Html
return
end if
Write-Debug "Saved newsletter.eml."
destroy loo_Email
destroy loo_Html