Concerning chastity, [Jesus] uttered such sentiments as these: “Whosoever looks upon a woman to lust after her, has committed adultery with her already in his heart before God.” And, “If your right eye offend you, cut it out; for it is better for you to enter into the kingdom of heaven with one eye, than, having two eyes, to be cast into everlasting fire.” And, “Whosoever shall marry her that is divorced from another husband commits adultery.” And, “There are some who have been made eunuchs of men, and some who were born eunuchs, and some who have made themselves eunuchs for the kingdom of heaven’s sake; but all cannot receive this saying” [Mt 19:12]. So that all who, by human law, are twice married, and those who look upon a woman to lust after her, are in the eye of our master sinners. For not only he who in act commits adultery is rejected by him, but also he who desires to commit adultery: since not only our works, but also our thoughts, are open before God. – First Apology 15 (151 A.D.)
When You Have An Evil Thought, Do This! | St. Alphonsus Liguori
"When an evil thought is presented to the mind, we must immediately endeavor to turn our thoughts to God, or to something which is indifferent. But the first rule is, instantly to invoke the names of Jesus and Mary and to continue to invoke them until the temptation...