Rejection and self confidence

How do you not beat yourself up after being used and rejected by someone you really loved? I feel like I must be ugly. I think about all my flaws. Or my personality must suck. I don’t want to feel this way.