ContentDisposition クラス

定義

MIME プロトコルの Content-Disposition ヘッダーを表します。

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

次のコード例では、インラインで表示する添付ファイルを含む電子メール メッセージを作成します。

static void CreateMessageInlineAttachment( 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"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 );
   data->~Attachment();
   client->~SmtpClient();
}
public static void CreateMessageInlineAttachment(string server, string
textMessage)
{
    // Create a message and set up the recipients.
    MailMessage message = new MailMessage(
       "jane@contoso.com",
       "ben@contoso.com",
       "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.
    message.Attachments.Add(data);
    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
    {
        client.Send(message);
    }
    catch (Exception ex)
    {
        Console.WriteLine("Exception caught in CreateMessageInlineAttachment: {0}",
            ex.ToString());
    }
    data.Dispose();
}

注釈

クラスの ContentDisposition 情報は、電子メール メッセージが送信先に送信されるときに添付ファイルを含む電子メール メッセージに付随します。 の ContentDisposition 情報は、送信者が意図した方法で電子メールの添付ファイルを表示するソフトウェアで使用できます。

Email メッセージは、 クラスのMailMessageインスタンスを使用して作成されます。 クラスのインスタンスは Attachment 、電子メール メッセージに添付ファイルを追加するために使用されます。 添付ファイルの を ContentDisposition 変更するには、 プロパティから インスタンスを Attachment.ContentDisposition 取得します。

メッセージ本文の一部として表示されるコンテンツの処理の種類は です Inline。 表示されていないが、別のファイルに添付されているコンテンツの処理の Attachment種類は です。 のインスタンスContentDispositionInline関連付けられている添付ファイルの処理の種類を制御するには、 プロパティを使用します。

添付ファイルの場合は、 のプロパティを使用して、ファイルの ContentDisposition サイズ、およびファイルの作成日、最終読み取り日、および最終変更日を設定できます。 すべての添付ファイルに対して、添付ファイルが受信側のコンピューターに保存されている場合に、推奨されるファイル名を設定できます。

メソッドは ToString Content-Disposition ヘッダーを返します。 Content-Disposition ヘッダーは、 で利用可能な RFC 2183 で https://www.ietf.org説明されています。

コンストラクター

ContentDisposition()

ContentDispositionDispositionType を使用して、Attachment クラスの新しいインスタンスを初期化します。

ContentDisposition(String)

指定した配置情報を使用して、ContentDisposition クラスの新しいインスタンスを初期化します。

プロパティ

CreationDate

添付ファイルの作成日付を取得または設定します。

DispositionType

電子メールの添付データの配置タイプを取得または設定します。

FileName

電子メールの添付データに割り当てられているファイル名を取得または設定します。

Inline

電子メールの添付データの配置タイプ (インラインまたは添付) を決定する Boolean 値を取得または設定します。

ModificationDate

添付ファイルの変更日を取得または設定します。

Parameters

このインスタンスによって表される Content-Disposition ヘッダー内に含まれるパラメーターを取得します。

ReadDate

添付ファイルの読み取り日を取得または設定します。

Size

添付ファイルのサイズを取得または設定します。

メソッド

Equals(Object)

指定した ContentDisposition オブジェクトの Content-Disposition ヘッダーが、このオブジェクトの Content-Disposition ヘッダーと等しいかどうかを判断します。

GetHashCode()

指定した ContentDisposition オブジェクトのハッシュ コードを確認します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

このインスタンスの String 形式を返します。

適用対象