Abdullah bin Abi Bakr bin Muhammad narrates from his father, and he from his grandfather (may Allah be pleased with him), that he heard the Messenger of Allah (peace and blessings be upon him) saying: "Whoever visits a sick person remains in the mercy of Allah as long as he sits with him and is immersed in it, and when he gets up from him he keeps wading in it until he returns to where he set out from. And whoever consoles (offers condolence to) his Muslim brother in a calamity, Allah Almighty will clothe him in garments of honour and dignity on the Day of Resurrection."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجنائز / 7087