Sayyiduna Abu Sa'id al-Khudri (may Allah be pleased with him) narrates that the Prophet (peace and blessings be upon him) said: "Envy is permissible only regarding two kinds of men: a man to whom Allah Almighty has given the Qur'an, and he keeps reciting it night and day, so another man says: 'If I had been given the like of what this person has been given, I would have done just as he does'; and a man to whom Allah Almighty has given wealth, and he spends it in its rightful way, so another person says: 'If I had been given what he has been given, I too would do just as he does.'"
This narration was recorded by Imam Abu Ya'la, and its narrators are the narrators of the "Sahih". Imam al-Bazzar recorded a similar narration.