Attachment::ContentDisposition Property
Gets the MIME content disposition for this attachment.
Assembly: System (in System.dll)
public: property ContentDisposition^ ContentDisposition { ContentDisposition^ get (); }
Property Value
Type: System.Net.Mime::ContentDispositionA ContentDisposition that provides the presentation information for this attachment.
The information in the ContentDisposition class represents the MIME Content-Disposition header. This header is described in RFC 2183, available at http://www.ietf.org.
The following code example gets the ContentDisposition for an attachment and displays its properties.
static void CreateMessageAttachment1( String^ server, String^ textMessage ) { // Create a message and set up the recipients. MailMessage^ message = gcnew MailMessage( L"jane@contoso.com",L"ben@contoso.com",L"A text message for you.",L"Message: " ); // Attach the message string to this e-mail message. Attachment^ data = gcnew Attachment( textMessage,MediaTypeNames::Text::Plain ); ContentDisposition^ disposition = data->ContentDisposition; // Suggest a file name for the attachment. disposition->FileName = String::Format( L"message{0}", DateTime::Now ); message->Attachments->Add( data ); //Send the message. SmtpClient^ client = gcnew SmtpClient( server ); client->Credentials = CredentialCache::DefaultNetworkCredentials; client->Send( message ); // Display the values in the ContentDisposition for the attachment. Console::WriteLine( L"Content disposition" ); Console::WriteLine( disposition ); Console::WriteLine( L"File {0}", disposition->FileName ); Console::WriteLine( L"Size {0}", disposition->Size ); Console::WriteLine( L"Creation {0}", disposition->CreationDate ); Console::WriteLine( L"Modification {0}", disposition->ModificationDate ); Console::WriteLine( L"Read {0}", disposition->ReadDate ); Console::WriteLine( L"Inline {0}", disposition->Inline ); Console::WriteLine( L"Parameters: {0}", disposition->Parameters->Count ); IEnumerator^ myEnum2 = disposition->Parameters->GetEnumerator(); while ( myEnum2->MoveNext() ) { DictionaryEntry^ d = safe_cast<DictionaryEntry^>(myEnum2->Current); Console::WriteLine( L"{0} = {1}", d->Key, d->Value ); } data->~Attachment(); client->~SmtpClient(); }
public:
static void CreateMessageAttachment1(String* server, String* textMessage)
{
// Create a message and set up the recipients.
MailMessage* message = new MailMessage(
S"jane@contoso.com",
S"ben@contoso.com",
S"A text message for you.",
S"Message: ");
// Attach the message string to this e-mail message.
Attachment* data = new Attachment(textMessage, MediaTypeNames::Text::Plain);
ContentDisposition* disposition = data->ContentDisposition;
// Suggest a file name for the attachment.
disposition->FileName = String::Format( S"message{0}", __box(DateTime::Now));
message->Attachments->Add(data);
//Send the message.
SmtpClient* client = new SmtpClient(server);
client->Credentials = CredentialCache::DefaultNetworkCredentials;
client->Send(message);
// Display the values in the ContentDisposition for the attachment.
Console::WriteLine(S"Content disposition");
Console::WriteLine(disposition);
Console::WriteLine(S"File {0}",disposition->FileName);
Console::WriteLine(S"Size {0}", __box(disposition->Size));
Console::WriteLine(S"Creation {0}", __box(disposition->CreationDate));
Console::WriteLine(S"Modification {0}", __box(disposition->ModificationDate));
Console::WriteLine(S"Read {0}", __box(disposition->ReadDate));
Console::WriteLine(S"Inline {0}", __box(disposition->Inline));
Console::WriteLine(S"Parameters: {0}", __box(disposition->Parameters->Count));
IEnumerator* myEnum2 = disposition->Parameters->GetEnumerator();
while (myEnum2->MoveNext())
{
DictionaryEntry* d = __try_cast<DictionaryEntry*>(myEnum2->Current);
Console::WriteLine(S"{0} = {1}", d->Key, d->Value);
}
data->Dispose();
client->Dispose();
}
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.