Compare fields and send a message I want to compare a term_reference field in a node with a term_reference field in a user profile. If certain terms match, I want to message the users with those matching terms. Is this something that could be achieved with rules?

EDIT:
This is my code so far:

dpm($node-&gt;field_project_resources);
dpm($node-&gt;field_project_resources['und']['0']['tid']);

$users = entity_load('user');
$arrayuids = array_keys($users);

$query = new EntityFieldQuery();    
$query-&gt;entityCondition('entity_type', 'profile2')
    -&gt;propertyCondition('uid', $arrayuids, 'IN');

$profile = $query-&gt;execute();

$arrayofpids = array();

foreach($profile as $obj){

     foreach($obj as $objinner)
     {
     array_push($arrayofpids, $objinner-&gt;pid);
     }

}
$profile2s = profile2_load_multiple($arrayofpids, FALSE);
foreach($profile2s as $obj){dpm($obj);
    foreach($obj as $objinner){
            if(is_array($objinner)){
           foreach($objinner as $i)
           {dpm($i);
                   foreach($i as $n)
                         {

                        }
           }}
    }
}


I want to compare for each value in array field_project_resources result with the profile2 array field of field_resources for each user and then return an array of users that have matching fields.
I am quite new to this and I would appreciate some help.
Yes, definitely something with rules together with http://drupal.org/project/mimemail (I would also recommend http://drupal.org/project/phpmailer together with mimemail), if you want to mail them, or use the https://drupal.org/project/messaging framework and notifications or similar.

You can use rules scheduler to do this on a schedule or use rules events such as "After saving a new term" to trigger the lookup when a term is saved. The tricky part is the conditions/actions of looking up. 

You can use the data comparison condition together with a php evaluation to lookup the user profile/term and then generate an action of sending a mail.

Or you may need to use fetch entity by id/property depending on what you have available to the situation to load the node and the same for the user profile, and then compare those results in a php custom action.

The last option is to use views bulk operations to do the lookup for you and then load the list in the rule using the views bulk operations action.