In our inner world as Jews, a titanic struggle is taking place between two implacable opponents: the evil inclination, also known as the bestial soul, and the good inclination, also known as the divine soul. Each side craves total control of the Jew’s thought, speech, and action, and will stop at nothing to accomplish its goal.
However, before discussing how to go about waging this war most effectively, let us come to terms with the most basic fact of this situation: In order to defeat the evil inclination, a Jew must fight, and he must fight enthusiastically and courageously. This is war.
(This is the reason that armies use anthems and march songs—in order to infuse morale and confidence in their forces. Similarly, football teams hire professional coaches to egg on their players .)
The Jew must believe that he can emerge victorious in his inner struggle, and that despite the odds against him, he will win. Then, with the help of Hashem, he stands a good chance of winning. If, however, he doubts his abilities; if he is feeling weak, depressed, and low, then he is bound to lose.
This is not only true of a person who suffers from depression for no apparent reason. Even if one’s sadness is totally legitimate and understandable, and no one will have any complaints against him for feeling that way, he must know that it must be overcome. The sadness is poison for his Neshamah, for it will weigh him down and sap him of the inner strength that he needs in order to defeat his evil inclination. And the more depressed he feels, the more easily the evil inclination will be able to entice him to sin.
In general, there are two legitimate reasons for sadness: Sadness from the awareness of one’s sins and the tremendous damage that they have wrought, and sadness from suffering that one has undergone.
In order to eliminate such sadness it is not sufficient to smile and clap one’s hands (although such external methods are recommended, as they may well significantly diminish the sadness, or at least help one cope with it). Each of these kinds of sadness can be eliminated by contemplating certain thoughts:
If one is sad about one’s sins, one should allocate a specific time (usually while reciting the Shema before going to sleep) in which to do Teshuvah. One should then consider one’s behavior, identify what one had done wrong, reflect upon the severity of the sins, regret them sincerely, and genuinely commit to changing in the future.
After this accounting and process of inner change is complete, one should believe wholeheartedly that Hashem has forgiven him, and be joyful.
Until then, when thoughts of past sins arise, one should simply make a mental note of them, and postpone further reflection on them to that designated time, knowing that the sadness at an inappropriate time is in fact a sneaky ploy of the evil inclination to weaken the Jew so that he falls prey to the enticements of the evil inclination.
If, however, the sadness has come from painful events in one’s life, G–d forbid, know and contemplate that in reality, these events are an expression of Hashem’s love. He is revealing to you a level of G–dliness that is so sublime that from your perspective, it is painful, because you lack the spiritual vessels to contain it. Work to refine yourself, and evoke love of Hashem within yourself, to the extent that knowing that you are experiencing a sublime level of divine revelation will lead you to joy, despite the difficulties of the external reality. As a reward for this joy, when Moshiach comes, you will be privileged to perceive this very divine revelation in all its glory, without experiencing any negative repercussions.
In summary, joy is vital for a Jew to serve Hashem well and overcome the evil inclination; conversely, sadness severely endangers one’s spiritual safety and must therefore be eliminated. Even legitimate sadness can and must be removed by using certain specific meditations, enabling the Jew to maintain an emotional state of joy, and thus have the upper hand in his war against the evil inclination.
 Cf. Tanya ch. 31: “בשעה שהוא עצב בלא"ה ממילי דעלמא או כך בלי שום סבה.”
 The Previous Rebbe said: “A soldier ... even though he enters a situation of danger, he goes forth with a joyful song ... he goes with joy, and this makes him the victor” (Sefer HaMa’amarim 5710, p. 191; quoted in Likkutei Sichos, Vol. 3, p. 799).
Adapted from Tanya, chs. 26, 9.