It is narrated from Sayyiduna Jabir (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) said that when any one of you is attracted to a woman, he should go to his wife, for this will remove the thoughts that have arisen in his heart.
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 15249