Sample code for 30+ languages & platforms
Classic ASP

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 Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
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".

set email = Server.CreateObject("Chilkat.Email")
email.Subject = "Set attachment disposition"

success = email.AddStringAttachment("image.txt","(pretend inline content)")

'  Set the disposition of the first attachment (index 0) to "inline".
success = email.SetAttachmentDisposition(0,"inline")
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( email.LastErrorText) & "</pre>"
    Response.End
End If

'  The attachment's Content-Disposition is now "inline".
Response.Write "<pre>" & Server.HTMLEncode( email.GetMime()) & "</pre>"

%>
</body>
</html>