PowerBuilder Requires Chilkat v11.0.0+
PowerBuilder
Create, save, and reopen a plain-text email
See more Email Object Examples
Set the sender, recipient, subject, and plain-text body. Save the result as an EML file, then open it in a second Email object and read its contents.
Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Email
oleobject loo_Received
li_Success = 0
// Assumes Chilkat is unlocked. See Global Unlock Sample.
loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
destroy loo_Email
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Email.From = "Sam Lee <sam@example.com>"
li_Success = loo_Email.AddTo("Alex Rivera","alex@example.net")
if li_Success <> 1 then
Write-Debug loo_Email.LastErrorText
destroy loo_Email
return
end if
loo_Email.Subject = "Hello"
loo_Email.Body = "This is a plain-text message."
li_Success = loo_Email.SaveEml("message.eml")
if li_Success <> 1 then
Write-Debug loo_Email.LastErrorText
destroy loo_Email
return
end if
loo_Received = create oleobject
li_rc = loo_Received.ConnectToNewObject("Chilkat.Email")
li_Success = loo_Received.LoadEml("message.eml")
if li_Success <> 1 then
Write-Debug loo_Received.LastErrorText
destroy loo_Email
destroy loo_Received
return
end if
Write-Debug loo_Received.From
Write-Debug loo_Received.Subject
Write-Debug loo_Received.GetPlainTextBody()
destroy loo_Email
destroy loo_Received