ContentDisposition.DispositionType Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene o imposta il tipo di eliminazione per un allegato di posta elettronica.
public:
property System::String ^ DispositionType { System::String ^ get(); void set(System::String ^ value); };
public string DispositionType { get; set; }
member this.DispositionType : string with get, set
Public Property DispositionType As String
Valore della proprietà
Oggetto String contenente il tipo di eliminazione. Il valore non è limitato, ma è in genere uno dei DispositionType valori.
Eccezioni
Il valore specificato per un'operazione set è null.
Il valore specificato per un'operazione set è uguale a Empty ("").
Esempio
Nell'esempio di codice seguente viene illustrato come impostare il valore di questa proprietà.
public static void CreateMessageWithAttachment4(string server, string to)
{
// Specify the file to be attached and sent.
// This example uses a file on a UNC share.
string file = @"\\share3\c$\reports\data.xls";
// Create a message and set up the recipients.
MailMessage message = new MailMessage(
"ReportMailer@contoso.com",
to,
"Quarterly data report",
"See the attached spreadsheet.");
// Create the file attachment for this email message.
Attachment data = new Attachment("qtr3.xls", MediaTypeNames.Application.Octet);
// Add time stamp information for the file.
ContentDisposition disposition = data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(file);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
disposition.ReadDate = System.IO.File.GetLastAccessTime(file);
disposition.DispositionType = DispositionTypeNames.Attachment;
// Add the file attachment to this email message.
message.Attachments.Add(data);
//Send the message.
SmtpClient client = new SmtpClient(server);
// Add credentials if the SMTP server requires them.
client.Credentials = (ICredentialsByHost)CredentialCache.DefaultNetworkCredentials;
client.Send(message);
// Display the message headers.
string[] keys = message.Headers.AllKeys;
Console.WriteLine("Headers");
foreach (string s in keys)
{
Console.WriteLine("{0}:", s);
Console.WriteLine(" {0}", message.Headers[s]);
}
data.Dispose();
}
Commenti
Il valore della DispositionType proprietà può essere usato dal software che visualizza il messaggio di posta elettronica per determinare il modo corretto per presentare gli allegati di posta elettronica. Inline gli allegati vengono in genere visualizzati quando l'utente apre il messaggio di posta elettronica. Attachment gli allegati in genere non vengono aperti finché l'utente non esegue un'azione, 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.