What is the function of the relative pronoun in the adjective clause?

After two years, I met the friend with whom I had exchanged many letters.

A.
possessive

B.
subject

C.
object of a preposition

D.
direct object