Hadrat Umar bin Al-Khattab (r.a.) reported: ‘The Messenger of Allah (saws) said, "The deeds are considered by the intentions, and a person will get the reward according to his intention. So whoever emigrated for Allah and His Messenger, his emigration will be for Allah and His Messenger; and whoever emigrated for worldly benefits or for a woman to marry, his emigration would be for what he emigrated for".
Related by Bukhari and Muslim.
The reward of each and every act depends entirely upon the intention which inspired the act. Thus only those deeds which are done with the sole intention to earn the Pleasure and Good Will of Allah Subhanah will be acceptable to the Lord Most Gracious…..but a deed, however noble it may seem, if done with the intention of anything else other than earning the Pleasure and Good Will of the Lord would not be eligible to earn any rewards in the Presence of the Lord on the Day of Judgment