“I'm sorry to hear that.”
Your friend was going to visit you from out of town, but he emailed to say that he wouldn't be able to make it. You want to show that you're disappointed that he's not coming. You write this back to him.
I'm sorry to hear that.
This is a polite phrase that you use when someone turns down an invitation.
You can also use this in other situations to respond to different kinds of bad news. You may need to add some words depending on how bad the news is. For more serious bad news, you can say:
I'm so sorry to hear that.