He took the pills for depression before the war, and didn't quit them until approximately June of 1865.
Wikipedia, here, so it must be true right?
For several years before his election to the presidency, Abraham Lincoln is known to have taken blue-mass pills for treatment of chronic melancholia.[5]
It’s been reported that during this time, Lincoln was known to have experienced neurological symptoms, including insomnia, tremor and rage attacks, which suggests he may have been suffering from mercury poisoning.
However, a few months after his inauguration, Lincoln reportedly stopped taking the medication because he perceived the pills made him "cross".[5]
In 2001, a study led by renowned public-health investigator Norbert Hirschhorn recreated a typical formulation,[6]concluding that the quantity of blue mass that Lincoln likely took would have delivered "a daily dose of mercury exceeding the current Environmental Protection Agency safety standard by over 9000 times,"[5] which may have adversely affected his health.
5."Lincoln's Little Blue Pills"(Press release). ScienceDaily: University Of Chicago Medical Center. 19 July 2001. Retrieved 2021-09-10.
6. Hirschhorn, Norbert; Feldman, Robert G.; Greaves, Ian (Summer 2001). "Abraham Lincoln's Blue Pills: Did Our 16th President Suffer from Mercury Poisoning?". Perspectives in Biology and Medicine. Johns Hopkins University Press. 44 (3): 315–322. doi:10.1353/pbm.2001.0048. PMID 11482002. S2CID 37918186. Retrieved 2021-09-10.