With a potential to facilitate the integration of renewable energy into the electricity system, electric drive vehicles may offer a considerable flexibility by allowing for charging and discharging when desired. This paper takes the perspective of an aggregator that manages the electricity market participation of a vehicle fleet and presents a framework for optimizing charging and discharging of the electric drive vehicles, given the driving patterns of the fleet and the variations in market prices of electricity. When the aggregator is a price-taker the optimization can be stated in terms of linear programming whereas a quadratic programming formulation is required when he/she has market power. A Danish case study illustrates the construction of representative driving patterns through clustering of survey data from Western Denmark and the prediction of electricity price variations through regression on prices from the Nordic market. The results show that electric vehicles provide flexibility almost exclusively through charging. Moreover, the vehicles provide flexibility within the day but only limited flexibility from day to day when driving patterns are fixed.