I had a similar problem with my 97 S320 and it turn out that the wiring harness bad (insulation on wires detorating) and the glass was bad.
The OEM replacement was roughly $500 (glass) but i was able to find a aftermarket for $300. I rewired the harness myself.
The procedure for removing the mirrow wass not difficult and i have listed below (might have left a few steps out

);
1) fold mirrow
2) remove inside cover at base of mirrow (snaps in place)
3) with cover removed you will have access to mounting screws
4) with the mirrow in the fold position you should have access to screws which hold the cover.
5) Once the cover is removed you should have access to wiring harness connector.
Sorry for being somewhat incomplete, memory fading.... smile