Trauma therapists use this technique with a very specific name — “unsent letter” or “empty chair.” It's used when confrontation isn't safe, isn't possible, or wouldn't be productive (the person is dead, they refuse to engage, they'll just deny it, or they're still in your life in a way that confrontation would break). The letter gives the feelings a destination even when the person can't be one.
The structure that works best is different from a love letter or a thank-you letter. You're not trying to make them feel anything — they're not reading it. You're trying to tell yourself, precisely, what happened and what it cost. Writing it precisely is what takes its power back.
Most people who write one write several. The first one is often rage. The second one is often grief. The third is often something like indifference — and that's when you realize you're further along than you thought.