Share via


ContentDisposition.Inline Proprietà

Definizione

Ottiene o imposta un valore Boolean che determina il tipo di disposizione (Inline o Attachment) per un allegato di posta elettronica.

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

Valore della proprietà

true se il contenuto nell'allegato viene presentato inline come parte del corpo del messaggio di posta elettronica; in caso contrario, false.

Esempio

Nell'esempio di codice seguente viene illustrato come impostare il valore di questa proprietà.

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

Commenti

La Inline proprietà imposta il tipo di eliminazione nell'intestazione Content-Disposition inviata con il messaggio di posta elettronica. Il tipo di eliminazione può essere usato dal software che visualizza la posta elettronica per determinare il modo corretto per presentare gli allegati di posta elettronica. Gli allegati con un tipo di disposizione di DispositionTypeNames.Inline vengono in genere visualizzati quando l'utente apre il messaggio di posta elettronica. Gli allegati con un tipo di disposizione di DispositionTypeNames.Attachment non vengono in genere aperti fino a quando l'utente non esegue un'azione aggiuntiva, ad esempio facendo clic su un'icona che rappresenta l'allegato.

L'intestazione Content-Disposition è descritta in RFC 2183 disponibile all'indirizzo https://www.ietf.org.

Si applica a