PowerBuilder
PowerBuilder
Create a Reply Email
See more Email Object Examples
Demonstrates the Chilkat Email.ToReply method, which generates a reply email with updated header and body fields so it can be sent as a reply. Attachments are excluded from the reply, but attached messages are included. The source email is not modified. This example creates a reply and prints its MIME.
Background: Replying is more than swapping sender and recipient: the
To is set from the original's reply address, the subject gets an Re: prefix, the original text is quoted, and threading headers (In-Reply-To, References) are added so mail clients group the conversation. ToReply assembles all of that, leaving a message you can edit and send. Dropping attachments is the usual reply convention — you rarely echo the sender's files back to them.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Email
oleobject loo_Reply
li_Success = 0
// Demonstrates the ToReply method, which generates a reply email with updated header and
// body fields ready to send as a reply. Attachments are excluded from the reply, but
// attached messages are included. The source email is not modified.
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.Subject = "Project update"
loo_Email.From = "alice@example.com"
loo_Email.AddTo("Bob","bob@example.com")
loo_Email.Body = "Here is the project update."
// Create a reply email based on this message.
loo_Reply = create oleobject
li_rc = loo_Reply.ConnectToNewObject("Chilkat.Email")
li_Success = loo_Email.ToReply(loo_Reply)
if li_Success = 0 then
Write-Debug loo_Email.LastErrorText
destroy loo_Email
destroy loo_Reply
return
end if
// The reply is addressed and quoted, ready to edit and send.
Write-Debug loo_Reply.GetMime()
destroy loo_Email
destroy loo_Reply