Sample code for 30+ languages & platforms
PowerBuilder

Load MIME from BinData

See more MIME Examples

Demonstrates the Chilkat Mime.LoadMimeBd method, which parses complete MIME bytes from a BinData and replaces the current MIME. The only argument is the BinData.

Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.

Background: This is the safest loader because it works on raw bytes: MIME can carry 8-bit content and even embedded NUL bytes that a text string would mangle, so loading from a BinData preserves the message exactly. Prefer it whenever the input is binary or of uncertain encoding — a downloaded message, a file read as bytes — over the string-based loaders.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Bd
oleobject loo_Mime

li_Success = 0

//  Demonstrates the Mime.LoadMimeBd method, which parses complete MIME bytes from a BinData and
//  replaces the current MIME.  The only argument is the BinData.  This is the preferred loader
//  when the MIME may contain arbitrary 8-bit or embedded NUL bytes.

loo_Bd = create oleobject
li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData")
if li_rc < 0 then
    destroy loo_Bd
    MessageBox("Error","Connecting to COM object failed")
    return
end if
li_Success = loo_Bd.LoadFile("qa_data/message.eml")
if li_Success = 0 then
    Write-Debug loo_Bd.LastErrorText
    destroy loo_Bd
    return
end if

loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")

li_Success = loo_Mime.LoadMimeBd(loo_Bd)
if li_Success = 0 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Bd
    destroy loo_Mime
    return
end if

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


destroy loo_Bd
destroy loo_Mime