Attachment.DisplayName プロパティ (Outlook)
埋め込まれた添付ファイルを表すアイコンの下に表示、実際のファイル名を指定する必要はありませんが、名前を表す 文字列 を設定または返します。 値の取得と設定が可能です。
構文
式。Displayname
式Attachment オブジェクトを表す変数。
注釈
このプロパティは、MAPI プロパティの PidTagDisplayName に対応しています。
例
このVisual Basic for Applications (VBA) の例では、Attachment.SaveAsFile メソッドを使用して、現在開いている項目の最初の添付ファイルをファイルとして Documents フォルダーに保存し、添付ファイルの表示名をファイル名として使用します。
Sub SaveAttachment()
Dim myInspector As Outlook.Inspector
Dim myItem As Outlook.MailItem
Dim myAttachments As Outlook.Attachments
Set myInspector = Application.ActiveInspector
If Not TypeName(myInspector) = "Nothing" Then
If TypeName(myInspector.CurrentItem) = "MailItem" Then
Set myItem = myInspector.CurrentItem
Set myAttachments = myItem.Attachments
'Prompt the user for confirmation
Dim strPrompt As String
strPrompt = "Are you sure you want to save the first attachment " & _
"in the current item to the Documents folder? If a file with the " & _
"same name already exists in the destination folder, " & _
"it will be overwritten with this copy of the file."
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
myAttachments.Item(1).SaveAsFile Environ("HOMEPATH") & "\My Documents\" & _
myAttachments.Item(1).DisplayName
End If
Else
MsgBox "The item is of the wrong type."
End If
End If
End Sub
関連項目
サポートとフィードバック
Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示