共用方式為


ContentDisposition.Inline 屬性

定義

取得或設定 Boolean 值,以判斷電子郵件附件的配置類型 (內嵌或附件)。

public:
 property bool Inline { bool get(); void set(bool value); };
public bool Inline { get; set; }
member this.Inline : bool with get, set
Public Property Inline As Boolean

屬性值

true 如果附件中的內容以內嵌方式呈現為電子郵件內文的一部分,則為 ;否則為 false

範例

下列程式碼範例示範如何設定此屬性的值。

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();
}

備註

屬性 Inline 會在以電子郵件訊息傳送的 Content-Disposition 標頭中設定處置類型。 配置類型可由顯示電子郵件的軟體使用,以判斷呈現電子郵件附件的正確方式。 當使用者開啟電子郵件時,通常會顯示處置類型的 DispositionTypeNames.Inline 附件。 在使用者執行一些額外的動作之前,通常不會開啟處置類型的 DispositionTypeNames.Attachment 附件,例如按一下代表附件的圖示。

Content-Disposition 標頭描述于 的 RFC 2183 中 https://www.ietf.org

適用於