PowerBuilder
PowerBuilder
Attach Email as message/rfc822 sub-part to an Email
See more Email Object Examples
Demonstrates how to add attach a message/rfc822 email to another email.Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Fac
oleobject loo_Email
oleobject loo_EmailToBeAttached
oleobject loo_Email2
li_Success = 0
// In this example, we'll attach an email loaded from a .eml file to a new email.
loo_Fac = create oleobject
li_rc = loo_Fac.ConnectToNewObject("Chilkat.FileAccess")
if li_rc < 0 then
destroy loo_Fac
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_EmlBytes = loo_Fac.ReadEntireFile("qa_data/eml/simple.eml")
loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
loo_Email.Subject = "This is a test email with an attached email."
loo_Email.Body = "Test with attached email."
loo_Email.AddTo("Joe","joe@example.com")
loo_Email.From = "mary@example.com"
li_Success = loo_Email.AttachMessage(loo_EmlBytes)
Write-Debug loo_Email.GetMime()
// ----------------------------------------------------------------------
// Alternatively, we could do this:
loo_EmailToBeAttached = create oleobject
li_rc = loo_EmailToBeAttached.ConnectToNewObject("Chilkat.Email")
li_Success = loo_EmailToBeAttached.LoadEml("qa_data/eml/simple.eml")
loo_Email2 = create oleobject
li_rc = loo_Email2.ConnectToNewObject("Chilkat.Email")
loo_Email2.Subject = "This is a test email with an attached email."
loo_Email2.Body = "Test with attached email."
loo_Email2.AddTo("Joe","joe@example.com")
loo_Email2.From = "mary@example.com"
loo_EmlBytes2 = loo_EmailToBeAttached.GetMimeBinary()
li_Success = loo_Email2.AttachMessage(loo_EmlBytes2)
Write-Debug "----"
Write-Debug loo_Email2.GetMime()
destroy loo_Fac
destroy loo_Email
destroy loo_EmailToBeAttached
destroy loo_Email2