The most difficult thing about loving someone is learning how to let them go. We are humans, therefore animals, and we can never control to whom we are attracted, it is just impossible. Dealing with rejection is always a problem, for we tend to turn love into hatred and good feelings into depression.
But how to overcome such powerful emotions? Unfortunately there is no magical formula, but loving yourself is a start. If you want to be ok, why not wish them to be ok too? After all, if you love them you should want them to be happy, with or without you. Hold no grudges, it is better for your health. It is not easy, but it is worth trying.