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

指定附件作为电子邮件正文的一部分显示。

适用于

另请参阅