ContentDisposition ContentDisposition ContentDisposition ContentDisposition Class


Represents a MIME protocol Content-Disposition header.

public ref class ContentDisposition
public class ContentDisposition
type ContentDisposition = class
Public Class ContentDisposition


The following code example creates an email message with an attachment to be displayed inline.

static void CreateMessageInlineAttachment( String^ server, String^ textMessage )
   // Create a message and set up the recipients.
   MailMessage^ message = gcnew MailMessage( L"",L"",L"An inline text message for you.",L"Message: " );
   // Attach the message string to this email message.
   Attachment^ data = gcnew Attachment( textMessage,MediaTypeNames::Text::Plain );
   // Send textMessage as part of the email body.
   message->Attachments->Add( data );
   ContentDisposition^ disposition = data->ContentDisposition;
   disposition->Inline = true;
   //Send the message.
   // Include credentials if the server requires them.
   SmtpClient^ client = gcnew SmtpClient( server );
   client->Credentials = CredentialCache::DefaultNetworkCredentials;
   client->Send( message );

public static void CreateMessageInlineAttachment(string server, string
	// Create a message and set up the recipients.
	MailMessage message = new MailMessage(
	   "An inline text message for you.",
	   "Message: ");

	// Attach the message string to this email message.
	Attachment data = new Attachment(textMessage, MediaTypeNames.Text.Plain);
	// Send textMessage as part of the email body.
	ContentDisposition disposition = data.ContentDisposition;
	disposition.Inline = true;
	//Send the message.
	// Include credentials if the server requires them.
	SmtpClient client = new SmtpClient(server);
	client.Credentials = CredentialCache.DefaultNetworkCredentials;

   try {
    catch (Exception ex) {
      Console.WriteLine("Exception caught in CreateMessageInlineAttachment: {0}", 
                  ex.ToString() );


The information in the ContentDisposition class accompanies an email message that contains attachments when the email message is sent to its destination. The information in ContentDisposition can be used by software that displays email to present the email attachments in the manner intended by the sender.

Email messages are created using instances of the MailMessage class. Instances of the Attachment class are used to add attachments to email messages. To modify the ContentDisposition for an attachment, get the instance from the Attachment.ContentDisposition property.

Content to be displayed as part of the message body has the disposition type of Inline. Content that is not displayed but is attached in a separate file has the disposition type of Attachment. Use the Inline property to control the disposition type for the attachment associated with an instance of ContentDisposition.

For file attachments, you can use the properties of the ContentDisposition to set the file size, as well as the date the file was created, last read, and last modified. For all attachments, you can set a recommended file name in the event that the attachment is stored on the receiving computer.

The ToString method returns the Content-Disposition header. The Content-Disposition header is described in RFC 2183 available at


ContentDisposition() ContentDisposition() ContentDisposition() ContentDisposition()

Initializes a new instance of the ContentDisposition class with a DispositionType of Attachment.

ContentDisposition(String) ContentDisposition(String) ContentDisposition(String) ContentDisposition(String)

Initializes a new instance of the ContentDisposition class with the specified disposition information.


CreationDate CreationDate CreationDate CreationDate

Gets or sets the creation date for a file attachment.

DispositionType DispositionType DispositionType DispositionType

Gets or sets the disposition type for an email attachment.

FileName FileName FileName FileName

Gets or sets the suggested file name for an email attachment.

Inline Inline Inline Inline

Gets or sets a Boolean value that determines the disposition type (Inline or Attachment) for an email attachment.

ModificationDate ModificationDate ModificationDate ModificationDate

Gets or sets the modification date for a file attachment.

Parameters Parameters Parameters Parameters

Gets the parameters included in the Content-Disposition header represented by this instance.

ReadDate ReadDate ReadDate ReadDate

Gets or sets the read date for a file attachment.

Size Size Size Size

Gets or sets the size of a file attachment.


Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the content-disposition header of the specified ContentDisposition object is equal to the content-disposition header of this object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Determines the hash code of the specified ContentDisposition object

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a String representation of this instance.

Applies to