Exchange MessageTrackingLogs get recipients list

From time to time we need to get a list of all persons to whom the email was sent with a given subject.

The list of recipients in a fairly simple way we can get from the transaction logs which are located on Exchange servers with HT roles.

Of course, before you do this, you have to configure your environment so that the transaction logs are kept for a few days on the servers.

The following script returns a list of recipients to whom the email was sent with the subject “Test mail”, but we are interested in the time of dispatch of the last day.

Number of days is defined in $DAYS and subject in $SUBJECT.

Script you can find below:

Continue reading