Attachments Collection

The Attachments collection contains all of the attachments to a message. The collection can be used to determine the total number of attachments to the message, or to access individual Attachment objects within the collection.

Syntax

Attachments.property|method

 

Properties
Count Returns the number of attachments in the collection.
Item Returns a reference to an attachment in the collection.
Methods
Remove Removes the attachment with the specified index from the collection.
RemoveAll Removes all the attachments from the collection.

 

Remarks

Item is the default property of the collection, so Attachments.Item(index) and Attachments(index) are equivalents.

To iterate through the collection, you can use either a For .. Each statement or any common loop statement such as For .. To.

 

Example

The following examples use different syntax to display filenames of all attachments to a message. It's assumed that the message has already been retrieved and stored in objMsg object.


For .. Each syntax
For Each objAttach In objMsg.Attachments
  MsgBox objAttach.Filename
  ' In ASP, use Response.Write instead of MsgBox
Next

 

For .. To syntax
For I = 1 To objMsg.Attachments.Count
  MsgBox objMsg.Attachments(I).Filename
  ' In ASP, use Response.Write instead of MsgBox
Next

 

See Also

Attachment Object, Message.Attachments Property

 


Send feedback to AfterLogic
Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.