Sample code for 30+ languages & platforms
PowerBuilder

Set a MIME Body from HTML

See more MIME Examples

Demonstrates the Chilkat Mime.SetBodyFromHtml method, which sets the body as HTML and changes the media type to text/html. The only argument is the HTML text.

Background: Setting an HTML body is how you produce the rich-formatted part of a message. Chilkat marks it text/html and chooses the encoding based on the content — 7bit for ASCII, a charset-aware encoding otherwise. In practice an HTML email is usually paired with a plain-text alternative inside a multipart/alternative so clients that cannot render HTML still have readable text.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mime
string ls_Html

li_Success = 0

//  Demonstrates the Mime.SetBodyFromHtml method, which sets the body as HTML and changes the media
//  type to text/html.  The only argument is the HTML text.

loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")
if li_rc < 0 then
    destroy loo_Mime
    MessageBox("Error","Connecting to COM object failed")
    return
end if

ls_Html = "<html><body><h1>Hello</h1><p>This is an HTML body.</p></body></html>"
li_Success = loo_Mime.SetBodyFromHtml(ls_Html)
if li_Success = 0 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Mime
    return
end if

Write-Debug "Content-Type: " + loo_Mime.ContentType


destroy loo_Mime