Sahih Muslim , Book 12, Hadith 99 (In-Book) ⓘ
Abu Huraira reported Allah's Apostle as saying: A man expressed his intention to give charity, so he came out with charity and placed it in the hand of an adulteress. In the morning, the people were talking and saying: charity was given to an adulteress last night. He (the giver of Sadaqa) said: 0 Allah, to Thee be the praise-to an adulteress. He then again expressed his intention to give charity; so he went out with the charity and placed it in the hand of a rich person. In the morning the people were talking and saying: Charity was given to a rich person. He (the giver of charity) said: 0 Allah, to Thee be the praise-to a well-to-do person. He then expressed his intention to give charity, so he went out with charity and placed it in the hand of a thief. In the morning, the people were talking and saying: Charity was given to a thief. So (one of the persons) said: 0 Allah, to Thee be the praise (what a misfortune it is that charity has been given to) the adulteress, to a rich person. to a thief! There came (the angel to him) and he was told: Your charity has been accepted. As for the adulteress (the charity might become the means) whereby she might restrain herself from fornication. The rich man might perhaps learn a lesson and spend from what Allah has given him, and the thief might thereby refrain from committing theft.
حَدَّثَنِي سُوَيْدُ بْنُ سَعِيدٍ، حَدَّثَنِي حَفْصُ بْنُ مَيْسَرَةَ، عَنْ مُوسَى بْنِ عُقْبَةَ، عَنْ أَبِي، الزِّنَادِ عَنِ الأَعْرَجِ، عَنْ أَبِي هُرَيْرَةَ، عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ " قَالَ رَجُلٌ لأَتَصَدَّقَنَّ اللَّيْلَةَ بِصَدَقَةٍ فَخَرَجَ بِصَدَقَتِهِ فَوَضَعَهَا فِي يَدِ زَانِيَةٍ فَأَصْبَحُوا يَتَحَدَّثُونَ تُصُدِّقَ اللَّيْلَةَ عَلَى زَانِيَةٍ . قَالَ اللَّهُمَّ لَكَ الْحَمْدُ عَلَى زَانِيَةٍ لأَتَصَدَّقَنَّ بِصَدَقَةٍ . فَخَرَجَ بِصَدَقَتِهِ فَوَضَعَهَا فِي يَدِ غَنِيٍّ فَأَصْبَحُوا يَتَحَدَّثُونَ تُصُدِّقَ عَلَى غَنِيٍّ . قَالَ اللَّهُمَّ لَكَ الْحَمْدُ عَلَى غَنِيٍّ لأَتَصَدَّقَنَّ بِصَدَقَةٍ . فَخَرَجَ بِصَدَقَتِهِ فَوَضَعَهَا فِي يَدِ سَارِقٍ فَأَصْبَحُوا يَتَحَدَّثُونَ تُصُدِّقَ عَلَى سَارِقٍ . فَقَالَ اللَّهُمَّ لَكَ الْحَمْدُ عَلَى زَانِيَةٍ وَعَلَى غَنِيٍّ وَعَلَى سَارِقٍ . فَأُتِيَ فَقِيلَ لَهُ أَمَّا صَدَقَتُكَ فَقَدْ قُبِلَتْ أَمَّا الزَّانِيَةُ فَلَعَلَّهَا تَسْتَعِفُّ بِهَا عَنْ زِنَاهَا وَلَعَلَّ الْغَنِيَّ يَعْتَبِرُ فَيُنْفِقُ مِمَّا أَعْطَاهُ اللَّهُ وَلَعَلَّ السَّارِقَ يَسْتَعِفُّ بِهَا عَنْ سَرِقَتِهِ " .
also referenced under: Hadith 1022 (Reference) & Book 5, Hadith 2230 (USC-MSA)