全部显示

Attachments 属性

       

返回 Attachments 对象,代表指定项目的所有附件。

expression.Attachments

expression  必选。该表达式返回“应用于”列表中的一个对象。

示例

本 Visual Basic for Applications 示例在将转发的邮件发送给 John Y.Chen 之前,使用 Remove 方法删除其中的所有附件。

Set myOlApp = CreateObject("Outlook.Application")
Set myinspector = myOlApp.ActiveInspector
If Not TypeName(myinspector) = "Nothing" Then
      Set myitem = myinspector.CurrentItem.Forward
      Set myattachments = myitem.attachments
        If Not TypeName(myattachments) = "Nothing" Then
         While myattachments.Count > 0
             myattachments.Remove 1
         Wend
         myitem.Recipients.Add "John Y. Chen"
         myitem.Send
        End If
   MsgBox "The current item is not of the correct type"
Else
  MsgBox "There is no active Inspector"
End If

如果使用 VBScript,则不必创建 Application 对象。本示例说明如何使用 VBScript 执行相同任务。

Set myinspector = Application.ActiveInspector
If Not TypeName(myinspector) = "Nothing" Then
      Set myitem = myinspector.CurrentItem.Forward
      Set myattachments = myitem.attachments
        If Not TypeName(myattachments) = "Nothing" Then
         While myattachments.Count > 0
             myattachments.Remove 1
         Wend
         myitem.Recipients.Add "John Y. Chen"
         myitem.Send
        End If
   MsgBox "The current item is not of the correct type"
Else
  MsgBox "There is no active Inspector"
End If