DisplayName Property

Microsoft Outlook Visual Basic

DisplayName Property

       

For Attachment object:

Returns or sets a String representing the name, which need not be the actual file name, displayed below the icon representing the embedded attachment. This property corresponds to the MAPI property PR_DISPLAY_NAME. Read/write.

For FormDescription object:

Returns or sets a String representing the name of the form, whish is what will be displayed in the Choose Forms dialog box. If both FormDescription.Name and FormDescription.DisplayName properties are empty, setting one will set the other. If one has been previously set, setting the other will not change the value. Read/write.

expression.DisplayName

expression    Required. An expression that returns an Attachment or FormDescription object.

Example

This Visual Basic for Applications example uses the SaveAsFile method to save the first attachment of the currently open item as a file in the My Documents folder, using the attachment's display name as the file name.

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
   

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using 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