When a person finds himself in a situation of "after sunset," when the light of day has given way to gloom and darkness, one must not despair, G-d forbid, but on the contrary, one must fortify oneself with complete trust in G-d, the Essence of Goodness, and take heart in the firm belief that the darkness is only temporary, and it will soon be superseded by a bright light, which will be seen and felt all the more strongly through the supremacy of light over darkness, and by the intensity of the contrast.
... Similarly, with regard to each individual, those who find themselves in a state of personal exile, there is no cause for discouragement and despondence, G-d forbid. On the contrary, one must find increasing strength in complete trust in the Creator and Master of the Universe, that his personal deliverance from distress and confinement is speedily on its way.
A letter from the Rebbe, 15 Kislev 5738 (1978)
It is explained in Torah Or (Parshas Toldos) that one should utilize depression for the sake of learning assiduously.
Igros Kodesh of the Rebbe, vol. 3, p. 370