I need to put this in a better sentence:

Upon his rejection, he realizes how he has been acting and when he writes the letter to explain his actions, it changes his character towards Elizabeth.

Upon his rejection and realization about how he has been acting, he writes the letter explaining his actions and that changes his character toward Elizabeth?

Sra

P.S. It had to be all in one sentence? You could shorten it, using a ; for the rest of it.