Its not so much a question of the longevity of the physical motor itself....its that of the fuel system/sensors/computers/gobs of gook that run it. After my intense initial parts throwing escapade, our 300E has proven to be very nice and reliable. M103's should be good for about 200-250k without major work (aside from the high likelyhood of a headgasket replacement) depending how they are driven. Ours has 136k and can still pull hard and strong to 110+mph and doesn't use much oil at all.
The M104 is probably similar, but its a more complex motor.
Bottom line: A gasser will need more ongoing care to be happy and reliable than a diesel, especially a 240.

I like the variety working on both types....even though it seems I do most of my work on the gasser....
__________________
-diesel is not just a fuel, its a way of life-

'15 GLK250 Bluetec 118k - mine - (OC-123,800)
'17 Metris(VITO!) - 37k - wifes (OC-41k)
'09 Sprinter 3500 Winnebago View - 62k (OC - 67k)
'13 ML350 Bluetec - 95k - dad's (OC-98k)
'01 SL500 - 103k(km) - dad's (OC-110,000km)
'16 E400 4matic Sedan - 148k - Brothers (OC-155k)