Platform SDK: Exchange 2000 Server

Attachments Property

[This is preliminary documentation and subject to change.]

Returns the collection of attachments in a message.

[Visual Basic,VBScript]
Property Attachments As IBodyParts
read-only
[C++]
HRESULT get_Attachments(IBodyParts** pVal);
[IDL]
HRESULT [propget] Attachments([out,retval] IBodyParts** pVal);

Remarks

Attachments are stored as body parts in a message's MIME hierarchy. The Attachments property returns a collection of objects that expose the IBodyPart interface, each of which is deemed to be an attachment by the implementing COM class. In most cases, attachments are flagged as such by setting the MIME header Content-Disposition to "attachment." However, a given body part's exact status insofar as whether it is an attachment is implementation dependent.

For more information on body parts and MIME structures, see Creating MIME-Formatted Messages.

Example

The following code determines the number of attachments in a message:

[Visual Basic]
Dim iMsg As New CDO.Message ' message to be inspected 
Dim collAtts As CDO.IBodyParts ' attachments collection of message 
' ... assume message is valid ... 
Set collAtts = iMsg.Attachments ' see if there is a collection 

If collAtts.Count = 0 Then 
MsgBox "Attachments collection exists but is empty"
Else 
MsgBox "Message has " & collAtts.Count & " attachments" 
End If