Loop through node reference I want to send emails using email stored on node fields that are referenced twice by other two contents types. I have this content types relationship:

Content1                 
field1 (unlimited) - reference &gt; Content2    
                                 field2 (only 1) - reference &gt; Content3
                                                               email


I want to send a email message to all itens on field1 using email field on Content3, after the node is created or updated.

I dont have experience with Rules looping. Ill appreciate any help.

Thanks!
The Rule will react on event "After updating existing content of type Content1".

The Rule will have to utilize a component in order to reach the email field in Content3.

In short: Rule loops through Content1 reference field (may contain multiple references) and then component will process each referenced node of type Content2 and return a variable back to the Rule. Returned variable contains an email that is taken from the field of the node of type Content3.

STEP 1 - Create Rules Component (export below)

{ "rules_process_content2_return_email" : {
    "LABEL" : "Process Referenced Content2 Entity and Return Email",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "content2" : { "label" : "Content2", "type" : "node" },
      "email_address" : { "label" : "Email Address", "type" : "text", "parameter" : false }
    },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "content2" ], "field" : "field_content_reference_2" } },
      { "entity_has_field" : {
          "entity" : [ "content2:field-content-reference-2" ],
          "field" : "field_email"
        }
      }
    ],
    "DO" : [
      { "variable_add" : {
          "USING" : {
            "type" : "text",
            "value" : [ "content2:field-content-reference-2:field-email" ]
          },
          "PROVIDE" : { "variable_added" : { "email_address" : "Email Address" } }
        }
      },
      { "data_set" : {
          "data" : [ "email-address" ],
          "value" : [ "content2:field-content-reference-2:field-email" ]
        }
      }
    ],
    "PROVIDES VARIABLES" : [ "email_address" ]
  }
}


STEP 2 - Create the Rule that uses Component above (export below)

{ "rules_send_email" : {
    "LABEL" : "Send Email",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_update--content1" : { "bundle" : "content1" } },
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "node:field-content-reference" ] },
          "ITEM" : { "content2_item" : "Content2 item" },
          "DO" : [
            { "component_rules_process_content2_return_email" : {
                "USING" : { "content2" : [ "content2-item" ] },
                "PROVIDE" : { "email_address" : { "email_address" : "Email Address" } }
              }
            },
            { "mail" : {
                "to" : "[email-address:value]",
                "subject" : "Test Email on Content1 Update",
                "message" : "[node:title] was updated",
                "language" : [ "" ]
              }
            }
          ]
        }
      }
    ]
  }
}


Replace "content1", "content2" and machine names of fields with your own content/fields machine names before importing. Modify to your liking.