All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
The required intention, which leads to receiving the reward, is to perform the act of worship seeking the countenance of Allah (i.e. to obey Him and please Him) and to draw closer to Him. If the person does so, he is entitled to receive the reward of that act of worship regardless of whether or not he knows what it is, and regardless of whether his intention was to receive that reward or not.
Al-Qaadhi pertaining to the definition of the intention enjoined by the Sharia, wrote, "Intention means a resolve to do an act for the sake of Allah and in compliance with His command..."
That said, when a person performs the Dhuha prayer, for instance, he earns the reward for it even if he did not hold the intention of earning that reward as long as he offered the prayer for the sake of Allah. As for the ahaadeeth urging people to carry out such acts of worship and righteous deeds to earn their great rewards, they are meant to encourage people and urge them to hasten to perform such acts of worship and beware of neglecting them. They do not mean that the person earns only the rewards that he intends when performing the act of worship.
There is no doubt that the grace of Allah has no limits. When the person is ignorant of the rewards that a given good deed yields, he still obtains them when he performs that deed, like the man who gave water to a thirsty dog and Allah rewarded him by forgiving his sins, and like the person who speaks a good word without knowing its worth and Allah blesses him with His Pleasure till the day that he will meet Him. There are many examples to this effect. This is quite clear; all praise be to Allah.
Allah knows best.