PowerBuilder
PowerBuilder
Load an Email from MIME in a BinData
See more Email Object Examples
Demonstrates the Chilkat Email.SetFromMimeBd method, which loads an email from the MIME stored in a BinData object. On success, it replaces the entire current email. This example serializes one email into a BinData with GetMimeBd, then reconstructs it in a second object.
Background: This is the binary counterpart to
SetFromMimeText and SetFromMimeSb. When a message's raw MIME arrives as bytes — read from a file, a socket, or a database blob into a BinData — loading it directly avoids any lossy or awkward byte-to-text conversion, which matters because MIME can carry binary transfer encodings.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Source
oleobject loo_BdMime
oleobject loo_Email
li_Success = 0
// Demonstrates the SetFromMimeBd method, which loads an email from MIME stored in a BinData
// object. On success, it replaces the entire current email.
// Build a source email and serialize its MIME into a BinData.
loo_Source = create oleobject
li_rc = loo_Source.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
destroy loo_Source
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Source.Subject = "Source message"
loo_Source.From = "alice@example.com"
loo_Source.Body = "Hello from a BinData."
loo_BdMime = create oleobject
li_rc = loo_BdMime.ConnectToNewObject("Chilkat.BinData")
loo_Source.GetMimeBd(loo_BdMime)
// Load a new email object from the BinData MIME.
loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
li_Success = loo_Email.SetFromMimeBd(loo_BdMime)
if li_Success = 0 then
Write-Debug loo_Email.LastErrorText
destroy loo_Source
destroy loo_BdMime
destroy loo_Email
return
end if
Write-Debug "Loaded subject: " + loo_Email.Subject
destroy loo_Source
destroy loo_BdMime
destroy loo_Email