That is a common E39 fault. It has been posted here before numerous times and I have shared my experience. If your mileage is not too high, you could try writing in to BMW customer relations, they might be able to offer something.
Do a search for the topics here, sorry I don't have time now to repost the details.