Umm Salama bint Abu Umaya reported,

The Messenger of Allah ﷺ said, "When you are present with a sick person or someone dying, speak words of goodness, for the angels say amen to what you say."She said, "When Abu Salama died, I went to the Prophet ﷺ and said, 'Messenger of Allah, Abu Salama has died.'"He replied, "Say, 'O Allah, forgive me and him, and grant me a good successor after him.'"

Azami 3465

Sahih

عن أم سلمة قالت

قال رسول الله ﷺ: إذا حضرتم المريض أو الميت، فقولوا خيرا، فإن الملائكة يؤمنون على ما تقولون قالت: فلما مات أبو سلمة أتيت النبي ﷺ فقلت: يا رسول الله إن أبا سلمة قد مات قال: قولي: اللهم اغفر لي وله، وأعقبني منه عقبى حسنة.

الأعظمي 3465صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Funerals
Chapter
Visiting the sick
Section
Nothing should be said in the presence of the sick except good, and what was said about giving them glad tidings
Numbering
Jami al-Kamil 3465 (2nd edition)
Azami 3465