Avoid a high milage non-M V8 E39 like the plague.
Based on your needs outlined in your post; the most sensible, cheapest to own and operate (gas, maint, existing parts supply): the clear logical choice is the E46 330.
Around 8K, you may even find a high mileage early E90 323/325. If it's feasible, I'd get that. You get a change of platform and much newer tech and better reliability than any E46. You can still use your wheels on this.
'02 ///M5 Imola Red / Imola Red '09 335i Alpine White / Coral Red