Use who when the pronoun is the subject of its clause. Use whom for an object when you want the formal form. In everyday English, who is common in object questions such as Who did you invite?

Examples explained
Who sent the invitation?
Why it works: Rearrange it as They sent the invitation. They is the subject, so use who.
Whom did you invite?
Why it works: Rearrange it as You invited them. Them is the object, so whom is the formal choice.
To whom should I give the invitation?
Why it works: In formal writing, whom is usual directly after a preposition such as to.
Find the clause that sets the role
In Who do you think sent the invitation?, start with They sent the invitation. The pronoun belongs to sent as its subject. The same check works in a relative clause, as in the neighbor who sent the invitation.
Formal and everyday wording
With whom did you speak? and Who did you speak with? ask the same question. The first puts the preposition next to its object and uses the formal whom. The second moves the preposition to the end and uses everyday who. You don’t have to use the more formal version in a conversation or casual email.
Watch the embedded clause: In Whom do you think the panel will choose?, test the panel will choose them. The person is the object of choose, unlike the subject of sent in the previous example.
Quick check
Choose the formal form, who or whom.
- ___ wrote the note?
- To ___ should I address the letter?
- ___ do you think left the note?
- In formal writing: ___ do you think the panel will choose?
Reveal the answers and explanations
Who. The pronoun is the subject: They wrote the note.
Whom. It is the object of to. This question asks for the formal form; everyday English commonly uses Who should I address the letter to?
Who. The pronoun is the subject of left: They left the note. Do you think does not change that role.
Whom. Try the panel will choose them. The pronoun is the object of choose.