Share via


Attachment.Name 属性

定义

获取或设置与此附件关联的内容类型中的 MIME 内容类型名称值。

public:
 property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string? Name { get; set; }
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String

属性值

String,包含由 Name 属性表示的内容类型 name 的值。

例外

为集运算指定的值为 null

为设置操作指定的值为 Empty ("")。

示例

下面的代码示例演示如何显示有关附件的信息。

static void DisplayFileAttachment( Attachment^ a )
{
   Console::WriteLine( L"Content Disposition {0}", a->ContentDisposition );
   Console::WriteLine( L"Content Type {0}", a->ContentType );
   Console::WriteLine( L"Name {0}", a->Name );
}
public static void DisplayFileAttachment(Attachment a)
{
    Console.WriteLine("Content Disposition {0}", a.ContentDisposition.ToString());
    Console.WriteLine("Content Type {0}", a.ContentType.ToString());
    Console.WriteLine("Name {0}", a.Name);
}

注解

属性 Name 用于为此附件生成的 Content-Type 标头。 Name收到包含附件的电子邮件时,将显示为附件的名称。 RFC 2045 第 5.1 节介绍了详细说明 Content-Type 标头语法的语法。 RFC 2046 提供有关 MIME 媒体类型及其参数的详细信息。 这些 RFC 在 中提供 https://www.ietf.org/

适用于