I am a huge fan of Law & Order Criminal Intent. Recently, I heard the Jeff Goldblum character say that rejection is God's protection. It never feels good to receive a rejection letter from an agent or editor no matter what stage you are at in your writing career, but his comment made me look at rejection in a new way. Instead of feeling depressed when you receive that dreaded email, try asking yourself what could God (or the universe) be protecting you against? Is this a good time in your life for writing deadlines? Perhaps a positive change is coming and you need the extra time to enjoy your promotion, baby, grandchild, remodeling project, move to a new home, etc. Is the editor of the line known for huge rewrites that you would not welcome? Or maybe that editor is about to leave for another publisher. If she took you on, you might find her replaced by an editor that doesn't like your style. The publisher may be about to sell the company or face bankruptcy. There is always the chance that you are close to publication, but still need to learn a bit more about your craft and this rejection is protecting you from embarrassment.
If you choose to accept that rejection is a form of protection, then put that dreaded email behind you and continue to write and learn more about your craft. When you receive your contract, it will be a distant memory.