How to make the foreach loop do something when it finishes executing

foreach (GameObject boxObj in boxManager.boxesObject)
{
    if (boxObj.transform.position.Equals(nextBoxPosition))
    {
        boxObj.SendMessage("CanBoxMove");
    }
}

I have this foreach loop that checks if the position of the box after being pushed is equal to the position of another box, and I want to make it so that when there is nothing in front of the box it can be pushed. For that I need to make it so it runs the code to move it when no box is detected in the next position

I’m a little confused. Is CanBoxMove telling it to check or telling it to move? Would the moving of any one box affect the ability of any other box to move?