This paper presents an optimization framework to improve the energy efficiency and cost-effectiveness of fleets of commercial trucks operating pickups and deliveries in urban areas. As the electrification of transportation is moving from passenger cars to medium- and heavy-duty vehicles, the proposed analysis considers a fleet of pickup and delivery trucks that includes conventional internal combustion engine vehicles (ICEV), as well as battery electric vehicles (BEV), and plug-in hybrid electric vehicles (PHEV). Given a set of pickups and deliveries, and a fleet including different types of vehicles, the goal is twofold: assign the best vehicle to each task, and solve the vehicle routing problem, i.e., find the optimal route to navigate the vehicle from the origin to the destination(s). To estimate the energy consumption of the different vehicles, vehicle dynamics are considered, together with actual charging infrastructure and road data, including speed limits, road grade, and stop signs. Moreover, the total cost of ownership (TCO) is evaluated to estimate the cost-effectiveness of different fleet compositions and operations. To solve this problem, a hybrid simulated annealing (HSA) heuristic algorithm is proposed. The algorithm is validated against a benchmark exact solver based on mixed integer linear programming (MILP). The proposed methodology achieves optimal results with a 1.2% optimality gap compared to the benchmark, surpassing MILP in computational efficiency. The research findings highlight how fleet composition and operational strategies can vary significantly based on whether the focus is on energy efficiency, total cost of ownership, or a combination of the two, also depending on the number of years of operation. Simulation case studies in the Columbus, OH area demonstrate that integrating fleet and recharging infrastructure information alongside energy savings in vehicle routing problem solutions can achieve 20% to 50% savings in fleet operation costs compared to solely optimizing for minimum energy consumption.