How to not let paper rejection affect you?
It is next to impossible not to be affected emotionally by a rejection of a paper. You put in a lot of time, effort and hard work, so it is a perfectly natural reaction to have a short term issue with motivation. There is no need to suppress this, and it will include quite a bit of frustration if rejections keep happening.
One of the more important things when it comes to publishing is that you are convinced of and positive about your own work and you may have to regain this after a rejection, so that the short term effects do not turn into long term problems. This might be hard to achieve when fighting all by yourself. Everybody needs some positive feedback from time to time. So talking to other people like your advisor or your peers and asking for their feedback will help because if you keep learning from the discussions, your work and your confidence in it will improve.
Of course there is also the possibility that you are working on a dead end with a particular paper. After having overcome the initial emotional response, you should be able to figure out if this is the case, maybe with the help of others. Then it is best to move on and concentratre on other projects with a better chance of succeeding. There is no happiness in working in a dead end. It is impossible from the distance to tell if this is true in your case.