DispositionTypeNames Klasa

Definicja

Dostarcza ciągi używane do określania typu dyspozycji dla załącznika wiadomości e-mail.

public ref class DispositionTypeNames abstract sealed
public static class DispositionTypeNames
type DispositionTypeNames = class
Public Class DispositionTypeNames
Dziedziczenie
DispositionTypeNames

Przykłady

Poniższy przykład kodu ustawia typ dyspozycji załącznika.

static void CreateMessageInlineAttachment3( 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->DispositionType = DispositionTypeNames::Inline;
   
   //Send the message.
   // Include credentials if the server requires them.
   SmtpClient^ client = gcnew SmtpClient( server );
   client->Credentials = dynamic_cast<ICredentialsByHost^>(CredentialCache::DefaultNetworkCredentials);
   client->Send( message );
   data->~Attachment();
   client->~SmtpClient();
}
public static void CreateMessageInlineAttachment3(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.DispositionType = DispositionTypeNames.Inline;
    //Send the message.
    // Include credentials if the server requires them.
    SmtpClient client = new SmtpClient(server);
    client.Credentials = (ICredentialsByHost)CredentialCache.DefaultNetworkCredentials;
    client.Send(message);
    data.Dispose();
}

Uwagi

Wartości w tym wyliczeniu mogą służyć do ustawiania DispositionType właściwości załącznika wiadomości e-mail. Informacje w ContentDisposition klasie reprezentują nagłówek MIME Content-Disposition. Ten nagłówek jest opisany w artykule RFC 2183 dostępnym pod adresem https://www.ietf.org.

Pola

Attachment

Określa, że załącznik ma być wyświetlany jako plik dołączony do wiadomości e-mail.

Inline

Określa, że załącznik ma być wyświetlany w ramach treści wiadomości e-mail.

Dotyczy

Zobacz też