Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

RecipientAddress Property

Exchange Server 2003

The RecipientAddress property is an array that specifies the e-mail addresses of each message recipient. The RecipientAddress property is read-only.

Applies To

The RecipientAddress property is a member of the Exchange_MessageTrackingEntry Class.

Instance Path

The RecipientAddress property appears on instances of the \\COMPUTERNAME\ROOT\MicrosoftExchangeV2:Exchange_MessageTrackingEntry class.

MOF Syntax

[read] string RecipientAddress[];

Qualifiers

This property has no qualifiers.

Remarks

The number of elements in the RecipientAddress property array is also provided in the RecipientCount Property. Each element in the RecipientAddress array has a corresponding element in the RecipientStatus Property array.

Selecting Instances Using VBScript

The following example shows how to retrieve a list of Exchange_MessageTrackingEntry instances, and the RecipientAddress property, using the ExecQuery method.


'===============================================================
' Name:      ShowExchange_MessageTrackingEntry_Query_RecipientAddress
' Purpose:   Display each Exchange_MessageTrackingEntry found for the
'            specified Exchange server, and show the Recipient
'            information for each Exchange_MessageTrackingEntry
'            instance.
' Input:     strComputerName [string] the computer to access
'            intHoursToShow [integer] the number of hours before the
'            present time for which log entries will be shown.
'            intUTCOffset [integer] Local time offset from UTC
' Output:    Displays the RecipientAddress and RecipientStatus of
'            each recipient for each Exchange_MessageTrackingEntry.
'
'===============================================================
' IMPORTANT: This script may take a very long time to execute when run
'            on a heavily used Exchange server, or when a very long
'            intHoursToShow is given. This script uses the ExecQuery
'            programming style, and gives a lower limit to the
'            TimeLogged property. It is recommended that applications
'            specify lower and upper bounds for the TimeLogged
'            property to improve performance.
'===============================================================
Public Sub ShowExchange_MessageTrackingEntry_Query_RecipientAddress ( _
  strComputerName, intHoursToShow, intUTCOffset )

Const cWMINameSpace = "root/MicrosoftExchangeV2"
Const cWMIInstance = "Exchange_MessageTrackingEntry"

Dim strWinMgmts              ' Connection string for WMI
Dim objWMIExchange           ' Exchange Namespace WMI object
Dim listExchange_MessageTrackingEntries ' Exchange_MessageTrackingEntry
                             ' collection
Dim objExchange_MessageTrackingEntry ' An Exchange_MessageTrackingEntry
                             ' instance
Dim intRecipientIndex        ' A counter for the recipient and
                             ' recipient status arrays
Dim strWQLQuery              ' A string for the Query
Dim strQueryLanguage         ' A string for the Query Language
Dim dtListFrom               ' Date/Time start for log entry inclusion
Dim strStartDateTime         ' WMI time stamp for log entry inclusion

' Create the object string, indicating WMI (winmgmts), using the
' current user credentials (impersonationLevel=impersonate),
' on the computer passed to the function in strComputerName, and
' using the CIM namespace for the Exchange_MessageTrackingEntry
' provider.
strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//" & _
   strComputerName & "/" & cWMINameSpace
'
' Get an object using the string you just created.
Set objWMIExchange =  GetObject(strWinMgmts)
'
' Create a date in the string form expected by WMI.
' For example, 12 November 2001, 4:29:24 = 20011120042924.000000+000
' Time stamps in WMI are compared as strings, and the TimeLogged
' property is always given with zero offset from UTC.
'
' Get the UTC-adjusted log-entry cutoff time.
dtListFrom = DateAdd("h",(intHoursToShow - intUTCOffset),now)
'
' Initialize the time stamp string with the year.
strStartDateTime = year(dtListFrom)
' Add a leading zero for the month, if needed.
if (Month(dtListFrom) < 10) then strStartDateTime = strStartDateTime & "0"
' Add the month value to the string.
strStartDateTime = strStartDateTime & Month(dtListFrom)
' Add a leading zero for the day, if needed.
if (Day(dtListFrom) < 10) then strStartDateTime = strStartDateTime & "0"
' Add the day value to the string.
strStartDateTime = strStartDateTime & Day(dtListFrom)
' Add a leading zero for the hours, if needed.
if (Hour(dtListFrom) < 10) then strStartDateTime = strStartDateTime & "0"
' Add the hours value to the string.
strStartDateTime = strStartDateTime & Hour(dtListFrom)
' Add a leading zero for the minutes, if needed.
if (Minute(dtListFrom) < 10) then strStartDateTime = strStartDateTime & "0"
' Add the minutes value to the string.
strStartDateTime = strStartDateTime & Minute(dtListFrom)
' Add a leading zero for the seconds.
if (Second(dtListFrom) < 10) then strStartDateTime = strStartDateTime & "0"
' Add the seconds value to the string, the part for fractional
' seconds, and an empty UTC offset. The empty UTC offset is
' needed to match the offset used by the TimeLogged property.
strStartDateTime = strStartDateTime & Second(dtListFrom) & ".000000+000"
'
' Construct the WQL Query string. Note the double-quotes surrounding the
' previously constructed date string.
strWQLQuery = "SELECT RecipientCount, RecipientAddress, RecipientStatus " & _
    "FROM Exchange_MessageTrackingEntry " & _
    "WHERE TimeLogged > """ & strStartDateTime & """"

' Display the query string you just constructed.
WScript.echo "The query string to be used: "
WScript.echo "    " & strWQLQuery

' Set the WMI Query Language (WQL) indicator.
strQueryLanguage = "WQL"

' The instances are returned as a list of Exchange_MessageTrackingEntry
' instances in the Exchange namespace.
Set listExchange_MessageTrackingEntries = objWMIExchange.ExecQuery ( _
    strWQLQuery, strQueryLanguage)

' Indicate how many items were returned by the query.
WScript.echo "Number of items returned: " & _
    listExchange_MessageTrackingEntries.Count
'
' Iterate through the list of Exchange_MessageTrackingEntry objects.
For each objExchange_MessageTrackingEntry in _
   listExchange_MessageTrackingEntries
   '
   ' Display the value of the KeyID property.
   WScript.echo "KeyID = " & _
    "[" & TypeName(objExchange_MessageTrackingEntry.KeyID) & "] " & _
     objExchange_MessageTrackingEntry.KeyID
   '
   ' Display the value of the RecipientCount property.
   WScript.echo "    RecipientCount           = [" & _
     TypeName(objExchange_MessageTrackingEntry.RecipientCount) & "] " & _
    objExchange_MessageTrackingEntry.RecipientCount
   '
   ' Check whether there are any recipients listed.
   if (objExchange_MessageTrackingEntry.RecipientCount > 0) then
     ' If yes, then do the following:
     ' Display a heading.
     WScript.echo "        RecipientAddress : RecipientStatus"
     '
     ' Iterate through the recipient status arrays based on the
     ' number returned by RecipientCount.
     for intRecipientIndex = 0 to objExchange_MessageTrackingEntry.RecipientCount-1
       ' Display the value of the RecipientAddress and RecipientStatus properties.
       WScript.echo "        " & _
         objExchange_MessageTrackingEntry.RecipientAddress(intRecipientIndex) & _
         " : " & _
         objExchange_MessageTrackingEntry.RecipientStatus(intRecipientIndex)
       '
     ' Move to the next recipient.
     next
   else
     ' If no, indicate there no recipients listed.
     WScript.echo "    The RecipientAddress and RecipientStatus arrays were empty."
   end if
   '
   ' Move to the next Exchange_MessageTrackingEntry.
Next
end Sub

VBScript Example

The following example shows how to retrieve a list of Exchange_MessageTrackingEntry instances, and how to retrieve the RecipientAddress property.


'===============================================================
' Name:      ShowExchange_MessageTrackingEntry_RecipientAddress
' Purpose:   Display each Exchange_MessageTrackingEntry found for the
'            specified Exchange server, and show the RecipientAddress
'            and RecipientStatus properties for each
'            Exchange_MessageTrackingEntry instance.
' Input:     strComputerName [string] the computer to access
' Output:    Displays the KeyID of each Exchange_MessageTrackingEntry
'            and the RecipientAddress and RecipientStatus properties.
'
'===============================================================
' IMPORTANT: This script may take a very long time to execute when run
'            on a heavily used Exchange server, because the script
'            lists information about all message transfers recorded
'            in the message tracking logs. The GetInstances style
'            of access used in this script causes the WMI provider
'            to enumerate all log entries. To improve the performance
'            of scripts using Exchange_MessageTrackingEntry instances,
'            it is recommended you use WMI ExecQuery, and restrict
'            the results range with the TimeLogged property.
'===============================================================
Public Sub ShowExchange_MessageTrackingEntry_RecipientAddress ( strComputerName )

Const cWMINameSpace = "root/MicrosoftExchangeV2"
Const cWMIInstance = "Exchange_MessageTrackingEntry"

Dim strWinMgmts              ' Connection string for WMI
Dim objWMIExchange           ' Exchange Namespace WMI object
Dim listExchange_MessageTrackingEntries ' Exchange_MessageTrackingEntry
                             ' collection
Dim objExchange_MessageTrackingEntry ' A single Exchange_MessageTrackingEntry
                             ' instance
Dim intRecipientIndex        ' A counter for the recipient and recipient
                             ' status arrays

' Create the object string, indicating WMI (winmgmts), using the
' current user credentials (impersonationLevel=impersonate),
' on the computer passed to the function in strComputerName, and
' using the CIM namespace for the Exchange_MessageTrackingEntry provider.
strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//" & _
   strComputerName & "/" & cWMINameSpace
'
' Get an object using the string you just created.
Set objWMIExchange =  GetObject(strWinMgmts)
'
' The instances appear as a list of Exchange_MessageTrackingEntry
' instances in the Exchange namespace.
Set listExchange_MessageTrackingEntries = objWMIExchange.InstancesOf(cWMIInstance)
'
' Iterate through the list of Exchange_MessageTrackingEntry objects.
For each objExchange_MessageTrackingEntry in listExchange_MessageTrackingEntries
   '
   ' Display the value of the KeyID property.
   WScript.echo "KeyID = " & _
    "[" & TypeName(objExchange_MessageTrackingEntry.KeyID) & "] " & _
     objExchange_MessageTrackingEntry.KeyID
   '
   ' Check whether there are any recipients listed.
   if (objExchange_MessageTrackingEntry.RecipientCount > 0) then
     ' If yes, then do the following:
     ' Display a heading.
     WScript.echo "        RecipientAddress : RecipientStatus"
     '
     ' Iterate through the recipient status arrays based on the
     ' number returned by RecipientCount.
     for intRecipientIndex = 0 to objExchange_MessageTrackingEntry.RecipientCount-1
       ' Display the value of the RecipientAddress and RecipientStatus properties.
       WScript.echo "        " & _
         objExchange_MessageTrackingEntry.RecipientAddress(intRecipientIndex) & _
         " : " & _
         objExchange_MessageTrackingEntry.RecipientStatus(intRecipientIndex)
       '
     ' Move to the next recipient.
     next
   else
     ' If no, indicate there no recipients listed.
     WScript.echo "    The RecipientAddress and RecipientStatus arrays were empty."
   end if
   '
   ' Move to the next Exchange_MessageTrackingEntry.
Next
end Sub

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.