Rejection and self - esteem

HI
anyone here know how towith rejection and self - esteem in all sorts of matter?
How do you maintain your self esteem despite getting rejected and humiliated?
How do you tell yourself that you can do it when your situation is deemed hopeless by everybody and yourself

I struggle very much also with self-esteem and rejection issues right now. While I understand it's one of the features of depression or other mental illnesses, it's still difficult to deal with.
Do you feel as though you try so hard to be the best person you can be, try to be nice to everyone and do the right thing, yet keep failing? It's so upsetting and the internal bad dialogue can start not long after.
But over the years I've come to realise that self-esteem and rejection issues(when they really hurt inside) are just a part of depression and things can be magnified. Often when the depression begins to lift, so do the self-esteem issues.