DisplayName 属性

       

对于 Attachment 对象:

返回或设置在图标下显示的名称(不一定为实际的文件名),图标代表嵌入的附件。String 类型。该属性相当于 MAPI 的 PR_DISPLAY_NAME 属性,可读写。

对于 FormDescription 对象:

返回或设置窗体名,该名称将显示在“选择窗体”对话框中。如果 FormDescription.NameFormDescription.DisplayName 属性都为空,设置其中一个就会设置另一个。如果以前设置过其中一个属性,设置另一个不会改变前一个属性的值。String 类型,可读写。

expression.DisplayName

expression   必选。该表达式返回 AttachmentFormDescription 对象。

示例

本 Visual Basic for Applications 示例使用 SaveAsFile 方法将当前打开项目的第一个附件作为文件保存在“My Documents”文件夹中,用附件的显示名称作为文件名。

Set myOlApp = CreateObject("Outlook.Application")
Set myinspector = myOlApp.ActiveInspector
If Not TypeName(myinspector) = "Nothing" Then
   If TypeName(myinspector.CurrentItem) = "MailItem" Then
    Set myitem = myinspector.CurrentItem
    Set myAttachments = myitem.attachments
    myAttachments.Item(1).SaveAsFile "C:\" & _
    myAttachments.Item(1).DisplayName
   End If
   MsgBox "The item is of the wrong type."
End If
   

如果使用 VBScript,则不必创建 Application 对象。本示例说明如何使用 VBScript 执行相同任务。

Set myinspector = Application.ActiveInspector
If Not TypeName(myinspector) = "Nothing" Then
   If TypeName(myinspector.CurrentItem) = "MailItem" Then
    Set myitem = myinspector.CurrentItem
    Set myAttachments = myitem.attachments
    myAttachments.Item(1).SaveAsFile "C:\" & _
    myAttachments.Item(1).DisplayName
   End If
   MsgBox "The item is of the wrong type."
End If