Outlook) (Attachment 物件

代表文件或是包含在 Outlook 項目中之文件的連結。

註解

使用 附件 (索引) ,其中 index 是索引編號,可傳回單一 Attachment 物件。

使用 Add 方法可將附件新增至專案。

範例

下列 Visual Basic for Applications (VBA) 範例會建立新郵件、附加 Q496.xlsx 做為附件 (而非連結)、為附件指定一個描述性的標題,以及顯示郵件及附件。 此範例假設指定的試算表 Q496.xlsx 已在指定的路徑 D:\Documents 中。

Sub AddAttachment() 
 
 Dim myItem As Outlook.MailItem 
 
 Dim myAttachments As Outlook.Attachments 
 
 
 
 Set myItem = Application.CreateItem(olMailItem) 
 
 Set myAttachments = myItem.Attachments 
 
 myAttachments.Add "D:\Documents\Q496.xlsx", _ 
 
 olByValue, 1, "4th Quarter 1996 Results Chart" 
 
 myItem.Display 
 
End Sub

另請參閱

將檔案附加至訊息項目將 Outlook 連絡人項目附加至Email郵件限制 Outlook 的附件大小Email郵件修改 Outlook 的附件Email郵件Outlook 物件模型參考

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應