We analyze the performance of Coded Slotted ALOHA (CSA) protocols in scenarios where users are equipped with limited batteries that are recharged through Energy Harvesting (EH). First, we assume a Perfect Packet Recovery Scenario (PPRS) for which the received packets are decoded with no errors when there is no interference. We introduce Battery Outage Probability (BOP) as an extra performance metric; and, we derive the optimal EH-CSA transmission policies, which offer the maximum attainable traffic load while maintaining an asymptotically negligible Packet Loss Ratio (PLR), under specific rate and BOP constraints. We extend our study to Imperfect Packet Recovery Scenario (IPRS) where impairments at the physical layer, including channel estimation and channel decoding errors, will distort messages being passed through the iterative Successive Interference Cancellation (SIC) process. The distorted messages being passed through the SIC process potentially lead to error propagation. In order to track the error propagation process, we define the concept of <italic xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">Accumulated Noise plus Interference Power</i> (ANIP), and analytically track the evolution of its probability distribution. We employ our results to evaluate the bit error rates for different transmission policies for the case of IPRS. We also demonstrate the advantages of the optimal transmission policies through numerical examples for both PPRS and IPRS. Our results show that the optimal EH-CSA policies outperform the policies optimized for standard CSA without EH considerations, and the schemes that are optimal for PPRS are not necessarily optimal for the IPRS case. Furthermore, the EH-CSA optimal policies strictly outperform standard CRDSA when the system is required to support higher traffic loads.