PowerBuilder Requires Chilkat v11.0.0+
PowerBuilder
Forward an email as an attachment
See more Email Object Examples
Attach the original Email to a new message as a message/rfc822 part. The recipient can open the attached email and read its original headers and body.
Chilkat PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_Original
oleobject loo_Email
li_Success = 0
// Assumes Chilkat is unlocked. See Global Unlock Sample.
loo_Original = create oleobject
li_rc = loo_Original.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
destroy loo_Original
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Original.LoadEml("message.eml")
if li_Success <> 1 then
Write-Debug loo_Original.LastErrorText
destroy loo_Original
return
end if
loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
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_Original
destroy loo_Email
return
end if
loo_Email.Subject = "Forwarded message"
loo_Email.Body = "The original email is attached."
li_Success = loo_Email.AttachEmail(loo_Original)
if li_Success <> 1 then
Write-Debug loo_Email.LastErrorText
destroy loo_Original
destroy loo_Email
return
end if
li_Success = loo_Email.SaveEml("forward-as-attachment.eml")
if li_Success <> 1 then
Write-Debug loo_Email.LastErrorText
destroy loo_Original
destroy loo_Email
return
end if
Write-Debug "Saved forward-as-attachment.eml."
destroy loo_Original
destroy loo_Email