Sample code for 30+ languages & platforms
PowerBuilder

Get the HTML Body into a StringBuilder

See more Email Object Examples

Demonstrates the Chilkat Email.GetHtmlBodySb method, which returns the text/html body into a StringBuilder. If the first argument is true, the related images found in the MIME are inlined as base64 data URLs directly within the returned HTML. This example retrieves the HTML body without inlining images.

Background: The inline-images option is useful for producing self-contained HTML that displays correctly in a browser or web view without needing the separate related parts — each cid: reference is replaced by a data: URL holding the image bytes. Be aware this can substantially enlarge the HTML, since base64 embedding adds roughly a third to each image's size. Writing into a StringBuilder is efficient for that potentially large output.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Email
oleobject loo_SbHtml

li_Success = 0

//  Demonstrates the GetHtmlBodySb method, which returns the text/html body into a
//  StringBuilder.  If the first argument is true, related images found in the MIME are
//  inlined as base64 data URLs directly within the returned HTML.

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.Subject = "GetHtmlBodySb example"

loo_Email.SetHtmlBody("<html><body><b>Hello in HTML.</b></body></html>")

//  Get the HTML body into a StringBuilder (false = do not inline related images).
loo_SbHtml = create oleobject
li_rc = loo_SbHtml.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Email.GetHtmlBodySb(0,loo_SbHtml)
if li_Success = 0 then
    Write-Debug loo_Email.LastErrorText
    destroy loo_Email
    destroy loo_SbHtml
    return
end if

Write-Debug loo_SbHtml.GetAsString()


destroy loo_Email
destroy loo_SbHtml