Platform SDK: CDO 1.2.1

Parent Property (All CDONTS Library Objects)

The Parent property returns the parent of the object. Read-only.

Syntax

Set objParent = object.Parent 
 

Data Type

Object

Remarks

The Parent property in the CDO for NTS Library returns the immediate parent of an object. The immediate parent for each object is shown in the following table.

CDO for NTS Library object Immediate parent in object hierarchy
AddressEntry Message
Attachment Attachments collection
Attachments collection Message
Folder Session
Message Messages collection
Messages collection Folder, including Inbox or Outbox
Recipient Recipients collection
Recipients collection Message
Session Set to Nothing

The Parent property represents the immediate parent of the object, rather than the logical parent. For example, a folder contains a Messages collection, which contains Message objects. The Parent property for a message is the immediate parent, the Messages collection, rather than the logical parent, the Folder object.

The Session object represents the highest level in the hierarchy of CDO for NTS Library objects and its Parent property is set to Nothing. The AddressEntry object does not have a true hierarchical parent but can only be obtained through the Sender property of a Message object. Its Parent property returns the Message object.

For more information on the CDO for NTS Library object hierarchy, see CDO for NTS Object Model.

Example

This code fragment displays the Class of the parent Messages collection of a Message object:

' Function: Message_Parent 
Function Message_Parent() 
' error handling here ... 
If objOneMsg Is Nothing Then 
    MsgBox "Need to select a message; see Messages->Get*" 
    Exit Function 
End If 
' Immediate parent of message is the Messages collection 
MsgBox "Message immediate parent class = " & objOneMsg.Parent.Class 
' error handling code ... 
End Function 
 

To get to the Folder object, you have to take the parent of the Messages collection:

' Function: Messages_Parent 
' Purpose: Display the Messages collection Parent class value 
' See documentation topic: Parent property 
Function Messages_Parent() 
Set objMessages = objOneMsg.Parent 
' error handling here ... 
If objMessages Is Nothing Then 
    MsgBox "No Messages collection available" 
    Exit Function 
End If 
MsgBox "Messages collection parent class = " & objMessages.Parent.Class 
Exit Function 
' error handling here ... 
End Function