Greeting the opposite sex
Asma bint Yazid (radi Allahu anha) reported: “The Prophet (sal Allahu alaihi wa sallam) passed by us when we were with a party of women, and he greeted us.”
[Sunan Abu Dawud - Al-Albaani said: (it is) Sahih]
In other narrations: Sahl bin Sa’d (radi Allahu anhu) reported: There was a woman among us who would put beet root in a pot and add to it some ground barley. She used to cook them together. On returning from the Friday prayer, we would greet her and she would offer it to us. [Sahih Al-Bukhari]
Umm Hani (radi Allahu anha), the daughter of Abu Talib reported: I went to the Prophet (sal Allahu alaihi wa sallam) on the day of the conquest of Makkah. He was taking a bath and Fatimah was screening him with a cloth. I greeted him… (And she mentioned the rest of the Hadith). [Sahih Muslim]
We benefit from the above narrations that it is permissible for men to greet women with salaam and vice versa, according to the most correct opinion, but this greeting must be free of anything that may provoke desire in the person in whose heart is a disease, so as to be safe from fitnah.
If there is fear of fitnah being provoked by this greeting, then the woman (or the male) should refrain from either initiating or returning the greeting, because warding off fitnah by neglecting the greeting is warding off mischief, and warding off mischief takes precedence over doing something useful.
And Allah knows best!