thanks for the welcome and response!Welcome to the forum!
I'll deal with the first sentence. It should be "Il lui a écrit une lettre" : "He wrote a letter to her.
You really should open a new thread for the second sentence.
But those sentences mean the exact same thing!but the sentence is he wrote her a letter not he wrote a letter to her.
The problem is that English is confusing... because we get to drop the "to" if we put the "someone" earlier in the sentence. Compare:my teacher said to use lui when its "to" someone.