Platform SDK: CDO 1.2.1 |
The Count property returns the number of Recipient objects in the collection. Read-only.
objRecipColl.Count
Long
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.
' from the sample function Util_CopyMessage ' Copy all Recipient objects from one message’s collection to another Dim objOneMsg, objCopyMsg as Message Dim objRecipColl as Recipients ' source message Recipients collection Dim objOneRecip as Recipient ' individual recipient in target message ' ... verify valid messages ... Set objRecipColl = objOneMsg.Recipients For i = 1 To objRecipColl.Count Step 1 strRecipName = objRecipColl.Item(i).Name ' could be objRecipColl(i).Name since Item is default property If strRecipName <> "" Then Set objOneRecip = objCopyMsg.Recipients.Add If objOneRecip Is Nothing Then MsgBox "Unable to create recipient in message copy" Exit Function End If objOneRecip.Name = strRecipName objOneRecip.Address = objRecipColl.Item(i).Address objOneRecip.Type = objRecipColl.Item(i).Type End If Next i