i had the exact same problem, but on the driver's side. it sucked bad because water leaked onto my seat and i had to sit on towels for a while to keep my butt dry. here's a link to my post about it:
http://nicoclub.com/zerothread?id=88293
i just did like he said, but i used black silicone (bought from any auto parts store) on the outside and inside to match the black moulding on our 240's. actually, i had to do it twice. the first time worked great, but i didn't apply the silicone in a good enough length along the outside moulding. it started to leak again a month or two later.
for the outside, i tried to dry the moulding as much as i could with a hair drier. then i laid down a line of silicone between where the moulding meets the roof. then i used my finger to press that stuff into the crevice. you might want to tape off the metal roof so you don't get silicone on it. i did that twice to make sure there were no air pockets and that it was really in there.
for the inside, i dried it, scraped away the usless, soaked foamy black stuff you mentioned, and applied the silicone there too. i'm not sure if i was correct in applying it, but it worked for me.
oh and use rubber gloves
Modified by phuphyter at 1:18 AM 1/20/2005