PowerBuilder
PowerBuilder
Set the Content-Disposition of an Attachment
See more Email Object Examples
Demonstrates the Chilkat Email.SetAttachmentDisposition method, which sets the Content-Disposition value for the attachment at a given zero-based index. The default disposition is attachment. This example changes an attachment's disposition to inline.
Background: The
Content-Disposition header hints how a client should present a part: attachment means "offer it as a download," while inline means "display it within the message" (as an email client does with an embedded image). Setting it lets you control that behavior — though clients ultimately decide how to honor the hint.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Email
li_Success = 0
// Demonstrates the SetAttachmentDisposition method, which sets the Content-Disposition
// value for the attachment at the given zero-based index. The default disposition is
// "attachment".
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 = "Set attachment disposition"
loo_Email.AddStringAttachment("image.txt","(pretend inline content)")
// Set the disposition of the first attachment (index 0) to "inline".
li_Success = loo_Email.SetAttachmentDisposition(0,"inline")
if li_Success = 0 then
Write-Debug loo_Email.LastErrorText
destroy loo_Email
return
end if
// The attachment's Content-Disposition is now "inline".
Write-Debug loo_Email.GetMime()
destroy loo_Email