Sample code for 30+ languages & platforms
PowerBuilder

Load MIME from a String

See more MIME Examples

Demonstrates the Chilkat Mime.LoadMime method, which parses complete MIME text and replaces the current object's headers, body, and multipart tree. The only argument is the MIME string.

Background: MIME is the structure behind email messages and many other content containers — a set of headers, a blank line, then a body that may itself be a tree of nested parts. Loading parses that text into an object you can then inspect and modify part by part. A successful load fully replaces whatever the object held before, and Chilkat is tolerant of common real-world formatting quirks. When the content may contain raw 8-bit or NUL bytes, prefer LoadMimeBd so nothing is forced through a text string.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mime
string ls_MimeText

li_Success = 0

//  Demonstrates the Mime.LoadMime method, which parses complete MIME text and replaces the current
//  object's headers, body, and multipart tree.  The only argument is the MIME string.

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

//  The complete MIME text (headers, a blank line, then the body).
ls_MimeText = "Content-Type: text/plain~r~n~r~nThis is the body.~r~n"

li_Success = loo_Mime.LoadMime(ls_MimeText)
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