Mu'awiyah bin Qurrah (may Allah have mercy on him) said: My father, Sayyiduna Qurrah bin Iyas (may Allah be pleased with him), said: When you pass by a gathering, greet its people with salam. If they are engaged in something good, you will become their partner in it; and if they are engaged in something else, you will receive the reward for greeting them. This is how I heard the Messenger of Allah (peace and blessings be upon him) say it.
Hadith Referenceالمعجم الكبير للطبراني / باب القاف / 16111