If redirecting your thoughts, or otherwise distracting yourself, isn't working, sometimes it can be helpful to sit quietly with the thoughts and go directly into them for a period of time. A big part of cognitive behavioral therapy is experiencing the feelings and thoughts you are avoiding, and letting them pass in their own time. It can be difficult and uncomfortable, but generally, as you allow the thoughts to come and you move through them (don't fight them, but also don't invite them) they begin to lose their hold and power over you.
What would happen if you hand wrote a letter like what you are thinking about, but then instead of sending it, you put it through a shredder or burned it? It's possible that after you write it all down and reread it a few times, you'll have a good idea of the reality of how that interaction would play out irl- which might settle the urge too.
It's tough to have that compulsion. It's normal for codependency too. We're so used to fixing and trying that we feel lost without doing that sort of thing.
The fact that you question if it's your fault bodes well for you- a person who ruins things in a dysfunctional way doesn't conscientiously wonder and worry what they've done wrong. Remember, you're the one who tried and tried and tried to fix things. If she was receptive to actually fixing things, she would have gotten on the same page long ago and worked it out