There is an opinion which says that there are four possible scenarios, and in only one is it regarded as haraam for a man to shake hands with a non-mahram woman. These four scenarios are: when the one who is shaking hands does it for the sake of pleasure and finds pleasure in it; when he does it for the sake of pleasure but does not find pleasure in it; when he does not do it for the sake of pleasure but finds pleasure in it; and when he does not do it for the sake of pleasure and does not find pleasure in it.
Who is the author of this opinion? Does he belong to the Maaliki madhhab?.
In Mukhtasar al-Akhdari and other Maaliki books there is an indication that it is haraam to shake hands with a non-mahram woman according to the madhhab of Maalik (may Allah have mercy on him).
‘Aleesh said in Minah al-Jaleel Sharh Mukhtasar Khaleel (1/22): It is not permissible for a man to touch the face or hand of a non-mahram woman, and it is not permissible for them to put their hands together without a barrier. ‘Aa’ishah (may Allah be pleased with her) said: The Prophet (blessings and peace of Allah be upon him) never accepted the oath of allegiance (bay‘ah) of a woman by holding her hand; he would accept women’s oath of allegiance verbally. According to another report: His hand never touched the hand of a woman; rather he would accept their oath of allegiance verbally. End quote.
The details that you mentioned have to do with losing wudoo’ by touching; wudoo’ is broken in the event of seeking pleasure, or finding pleasure (even if he was not seeking it), or seeking it and finding it. Wudoo’ is not broken when one does not seek pleasure or find it.
The prohibition is connected to doing it deliberately, whether there is pleasure or not.
And Allah knows best.