MailItem.AttachmentRead イベント (Outlook)

親オブジェクトのインスタンスの添付ファイルが読み取り用に開かれると発生します。

構文

AttachmentRead( _Attachment_ )

expressionMailItem オブジェクトを表す変数です。

パラメーター

名前 必須 / オプション データ型 説明
Attachment 必須 Attachment 開かれた 添付ファイル です。

このVisual Basic for Applications (VBA) の例では、ユーザーが添付ファイルを読み取ろうとしたときにメッセージが表示されます。 サンプル コードは、 などの ThisOutlookSessionクラス モジュールに配置する必要があり、イベント プロシージャを TestAttachRead() Microsoft Outlook から呼び出す前にプロシージャを呼び出す必要があります。 この例を実行するには、受信トレイに少なくとも 1 つのアイテムがあり、件名が 'Test' で、少なくとも 1 つの添付ファイルが含まれている必要があります。

Public WithEvents myItem As outlook.MailItem 
 
 
 
Private Sub myItem_AttachmentRead(ByVal myAttachment As Outlook.Attachment) 
 
 If myAttachment.Type = olByValue Then 
 
 MsgBox "If you change this file, also save your changes to the original file." 
 
 End If 
 
End Sub 
 
 
 
Public Sub TestAttachRead() 
 
 Dim atts As Outlook.Attachments 
 
 Dim myAttachment As Outlook.Attachment 
 
 
 
 Set myItem = Application.ActiveExplorer.CurrentFolder.Items("Test") 
 
 Set atts = myItem.Attachments 
 
 myItem.Display 
 
End Sub

関連項目

MailItem オブジェクト

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。