Compartilhar via


Attachments Property

Returns an Attachments object that represents all the attachments for the specified item.

expression**.Attachments**

*expression   * Required. An expression that returns one of the objects in the Applies To list.

Example

This Visual Basic for Applications (VBA) example uses the Remove method to remove all attachments from a forwarded message before sending it on to 'Dan Wilson'. To run this example, replace 'Dan Wilson' with a valid recipient's name and keep an item with attachments open in an inspector window.

Sub RemoveAttachmentBeforeForwarding()
    Dim myolApp As Outlook.Application
    Dim myinspector As Outlook.Inspector
    Dim myItem As Outlook.MailItem
    Dim myattachments As Outlook.Attachments
    Set myolApp = CreateObject("Outlook.Application")
    Set myinspector = myolApp.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

Applies to | AppointmentItem Object | ContactItem Object | DistListItem Object | DocumentItem Object | JournalItem Object | MailItem Object | MeetingItem Object | PostItem Object | RemoteItem Object | ReportItem Object | TaskItem Object | TaskRequestAcceptItem Object | TaskRequestDeclineItem Object | TaskRequestItem Object | TaskRequestUpdateItem Object

See Also | PathName Property | Position Property