The result, though, would not be for the friend to relay your message directly in most cases, even though that may be how you phrase the request. More natural would be for the person you asked to relay your message instead to thank the person for taking care of you. If he's close enough to you to be asked to relay such a message then he is close enough that a kindness done to you is in itself a kindness done to him.
A and B are friends. C does some act of kindness for A. It is normal, natural, and expected that B appreciated what C did for A and expresses his own thanks for it, rather than merely relaying a message of thanks from A. Does that clear it up a bit? この前(内の)A君がお世話になりました。
You've probably heard of the uchi/soto dichotomy in Japanese society. It is in situations like this where it comes into play in a linguistic sense. (Also in the verbs of giving/receiving).