PowerBuilder
PowerBuilder
Serialize MIME to a StringBuilder
See more MIME Examples
Demonstrates the Chilkat Mime.GetMimeSb method, which serializes the complete MIME entity and appends it to a StringBuilder. The only argument is the StringBuilder; existing content is preserved.
Background: Serializing into a
StringBuilder avoids creating a new string and is convenient when you are accumulating output or building a larger document. Because it appends, you can assemble several pieces in one buffer. As with GetMime, use the BinData form for content with arbitrary binary bytes.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mime
oleobject loo_Sb
li_Success = 0
// Demonstrates the Mime.GetMimeSb method, which serializes the complete MIME entity and appends
// it to a StringBuilder. The only argument is the StringBuilder.
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
li_Success = loo_Mime.SetBodyFromPlainText("Hello, this is the message body.")
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
// Append the serialized MIME to a StringBuilder. Existing content is preserved.
loo_Sb = create oleobject
li_rc = loo_Sb.ConnectToNewObject("Chilkat.StringBuilder")
li_Success = loo_Mime.GetMimeSb(loo_Sb)
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
destroy loo_Sb
return
end if
Write-Debug loo_Sb.GetAsString()
destroy loo_Mime
destroy loo_Sb