共用方式為


Outlook) (MailItem.AttachmentRead 事件

會在已開啟父物件之執行個體中的附件進行讀取時發生。

語法

expressionAttachmentRead( _Attachment_ )

表達 代表 MailItem 物件的 變數。

參數

名稱 必要/選用 資料類型 描述
Attachment 必要 Attachment 已開啟的 Attachment

範例

這個 Visual Basic for Applications (VBA) 範例會在使用者嘗試讀取附件時顯示訊息。 範例程式碼必須放在類別模組中,例如 ThisOutlookSession ,而且 TestAttachRead() 應該先呼叫程式,Microsoft Outlook 才能呼叫事件程序。 如果要執行這個範例,[收件匣] 中至少要有一封主旨為 'Test' 的郵件,而且必須至少夾帶一個附件。

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 支援與意見反應