Count Property (CDONTS Recipients Collection)

The Count property returns the number of Recipient objects in the collection. Read-only.

Syntax

collRecips.Count 
 

Data Type

Long

Example

This code fragment uses the Count property as a loop terminator to copy all Recipient objects from one message's Recipients collection to another message's collection. It shows the Count and Item properties working together. Note how much more code this requires than copying the Message object's Recipients property from the original message to the copy.

' Copy all Recipient objects from one message's collection to another 
Dim objMessage, objCopyItem as Message 
Dim collRecips as Recipients ' source message Recipients collection 
Dim objRecip as Recipient ' individual recipient in target message 
' ... verify valid messages ... 
Set collRecips = objMessage.Recipients 
For i = 1 To collRecips.Count Step 1 
    strRecipName = collRecips.Item(i).Name 
'   could be collRecips(i).Name since Item is default property 
    If strRecipName <> "" Then 
        Set objRecip = objCopyItem.Recipients.Add 
        If objRecip Is Nothing Then 
            MsgBox "Unable to create recipient in message copy" 
            Exit Function 
        End If 
        objRecip.Name = strRecipName 
        objRecip.Address = collRecips.Item(i).Address 
        objRecip.Type = collRecips.Item(i).Type 
    End If 
Next i