Attachments Collection

Parent object: Message object.

An object reference to an Attachments collection is returned from a call to the Attachments property of a Message object.

The Attachments collection is a child of a Message object and contains zero or more Attachment objects. Use the Attachments collection to add new Attachment objects to a message or to access the attachments that are already part of the current message. Table 15.6 and Table 15.7 list the properties and methods of the Attachments collection, respectively.

Table 15.6. Attachments Collection Properties

Property

Description

Count

An integer value that represents the number of Attachment objects in the Attachments collection. This property is read-only.

Item

Returns a reference to a single Attachment object in the collection. This property is read-only.

Table 15.7. Attachments Collection Methods

Method

Description

Add

Adds an Attachment object to the Attachments collection. You can add Attachment objects to an Attachments collection only for a message you are sending.

Delete

Removes all the Attachment objects from the current Attachments collection. Be cautious when using the Delete method of the Attachments collection, since it deletes every Attachment object in the collection. To remove a single Attachment object from a collection, use the Delete method of the Attachment object.

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.