Share via


DispositionTypeNames 類別

定義

提供用來指定電子郵件附件之配置類型的字串。

public ref class DispositionTypeNames abstract sealed
public static class DispositionTypeNames
type DispositionTypeNames = class
Public Class DispositionTypeNames
繼承
DispositionTypeNames

範例

下列程式代碼範例會設定附件的處置類型。

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

備註

這個列舉中的值可用來設定 DispositionType 電子郵件附件的 屬性。 類別 ContentDisposition 中的資訊代表MIME Content-Disposition 標頭。 此標頭說明於 的 RFC 2183 中。https://www.ietf.org

欄位

Attachment

指定將附件顯示為附加至電子郵件訊息的檔案。

Inline

指定將附件顯示為電子郵件訊息內文的一部分。

適用於

另請參閱