共用方式為


Outlook) (Attachments.Remove 方法

會將物件從集合中移除。

語法

運算式移除 (索引)

表達 代表 Attachments 物件的 變數。

參數

名稱 必要/選用 資料類型 描述
Index 必要 Long 集合內物件的一維索引值。

範例

這個 Visual Basic for Applications (VBA) 範例會使用 Remove 方法,在將郵件傳送給 Dan Wilson 之前,先從轉寄的郵件中移除所有附件。 執行此範例前,請使用有效的收件者姓名取代 'Dan Wilson'。

Sub RemoveAttachmentBeforeForwarding() 
 
 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 
 
 Set myItem = myinspector.CurrentItem.Forward 
 
 Set myattachments = myItem.Attachments 
 
 While myattachments.Count > 0 
 
 myattachments.Remove 1 
 
 Wend 
 
 myItem.Display 
 
 myItem.Recipients.Add "Dan Wilson" 
 
 myItem.Send 
 
 Else 
 
 MsgBox "There is no active inspector." 
 
 End If 
 
End Sub

另請參閱

Attachments 物件

支援和意見反應

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