If I'd let rejection get to me I wouldn't be published today.
My first book was rejected nearly 30 times before finding a home. Of course in between rejections I rewrote the book several times. I did have an agent during that time and though he taught me a lot, he didn't send the book out at all.
Did the rejections end after that first published book? Heck no, the editor who bought that book left the house and her replacement wasn't interested in my next one. So I had to start all over again.
When I began writing mysteries I first sought an agent and had several. One agent I met at a writing conference had my Tempe series for about four years with no results, of course it didn't help that she only sent each book to one publisher. (Didn't find that out until I asked to see the rejections.)
Oh and before her I had another agent who wanted me to change Tempe Crabtree's name because it was too unusual. I didn't, of course.
For my Rocky Bluff P.D. series I had an agent for awhile who couldn't sell the first book. Finally I struck out on my own. I found a publisher in Writers Market who wanted police procedurals. He accepted the book but when I got the contract I learned he would be publishing electronically. This was eons ago before there were any e-readers of any kind. The book was wonderfully edited but only sold one copy and that was to me so I could see what it looked like.
I had a Christian horror I shopped around and found a publisher who wanted it camera ready. I struggled to make it that way and when it was done learned he had passed away.
My first mystery was published by an outfit that turned out to be crooked. They printed 50 of that book, I sold them all at a book signing and never heard from them again. I found a small publisher who reprinted that book and took on the first four of the Deputy Tempe Crabtree series. Sadly, she passed away. Later I met the publisher for Mundania Press who is now publishing all of that series.
Later I found another e-publisher who also did print books (by this time the Rocket e-Reader had come into existence) and he published the first two of the Rocky Bluff P.D. series. The problem with him was he never sent me any royalties.
Another publisher did print and e-books for the next two in that series and then decided that the publishing business was not for her.
I met the publisher of Oak Tree Press at a conference and asked her if she'd be interested in the Rocky Bluff P.D. series and she's published the latest two and put the others on Kindle.
Pat Browning reminded me of something another friend said about me, "When a publisher dies, Marilyn just steps over the body and finds another one."
Really, though the lesson here, is no matter what, if you really want to be a writer, don't give up.