This paper considers an ad hoc network with multiple transmitter-receiver pairs, in which all transmitters are capable of harvesting renewable energy from the environment and compete for the same channel by random access. To quantify the roles of both the energy state information (ESI) and the channel state information (CSI), a distributed opportunistic scheduling (DOS) framework with a save-then-transmit scheme is proposed. First, in the channel probing stage, each transmitter probes the CSI via channel contention; next, in the data transmission stage, the successful transmitter decides to either give up the channel (if the expected reward calculated over the CSI and ESI is small) or hold and utilize the channel by optimally exploring the energy harvesting and data transmission tradeoff. With a constant energy arrival model, i.e., the energy harvesting rate keeps identical over the time of interest, the expected throughput maximization problem is formulated as an optimal stopping problem, whose solution is shown to exist and have a threshold-based structure, for both the homogeneous and heterogenous cases. Furthermore, we prove that there exists a steady-state distribution for the stored energy level at each transmitter, and propose an efficient iterative algorithm for its computation. Finally, we show via numerical results that the proposed scheme can achieve a potential 175% throughput gain compared with the method of best-effort delivery.