ContentDisposition.Inline 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定一個 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
範例
以下程式碼範例示範如何設定此屬性的值。
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 附件通常不會開啟,直到使用者執行額外動作,例如點擊代表該附件的圖示。
內容-處置標頭在 RFC 2183 中有描述,該標頭可於 https://www.ietf.org。