PowerBuilder
PowerBuilder
Set a MIME Body from Plain Text
See more MIME Examples
Demonstrates the Chilkat Mime.SetBodyFromPlainText method, which sets the body as plain text. The only argument is the text. For ASCII input Chilkat uses text/plain with 7bit encoding; for non-ASCII it selects an appropriate charset and encoding.
Background: This is the simplest way to give a MIME entity a text body — Chilkat picks a sensible
Content-Type and transfer encoding for you based on the content. Plain ASCII stays as 7bit with no charset, while text containing accented or non-Latin characters gets a charset (typically UTF-8) and a suitable encoding so it survives transmission intact. It is the text counterpart to SetBodyFromHtml and SetBodyFromXml.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mime
string ls_MimeText
li_Success = 0
// Demonstrates the Mime.SetBodyFromPlainText method, which sets the body as plain text. The only
// argument is the text. For ASCII, Chilkat sets Content-Type: text/plain and a 7bit transfer
// encoding; for non-ASCII it selects an appropriate charset and encoding.
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 a plain-text message body.")
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
ls_MimeText = loo_Mime.GetMime()
if loo_Mime.LastMethodSuccess = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
Write-Debug ls_MimeText
destroy loo_Mime