English speakers live in a subject-object universe, which is an important thing to remember when dealing with pronouns such as "who" and "whom." In order to use these two words properly in a sentence, speakers need to know the difference between a subject and a direct object. "Who" usually takes the place of a subject, otherwise known as the nominative case. "Whom" generally replaces the direct object, also known as the accusative case.
A standard English sentence tends to follow a subject-verb-object pattern, although there are always variations. The subject either does something to the direct object, or else the subject just is the predicate nominative. In the sentence "I left class early today," the subject is "I." If a speaker wanted to turn that sentence into a question, he would use the subject form: "Who left class early today?" This word always replaces a noun acting as a subject or predicate nominative, as in "Someone as honest as Bill Johnson is who we need in office." While the actual subject may be "someone," the predicate nominative that matches "someone" is who. When the verb is considered intransitive, meaning it doesn't carry its action over to a direct object, then "who" is the proper pronoun to use.
On the object side of the sentence, however, things change. In the sentence "The teacher sent Alvin to the Principal's office," Alvin is the direct object or recipient of the action. A question formed from that sentence would read "Whom did the teacher send to the Principal's office?" This pronoun is the proper substitute for a noun being used as a direct object. "Whom shall I send?" could be reworked as "I shall send whom?" which might make the subject-verb-direct object relationship clearer. This term will never be used as the subject of a sentence, and "Who" will never be used in place of a direct object.
When in doubt, speakers or writers can use a quick substitution to decide between these terms. By substituting "I" or "me," the speaker should be able to hear which pronoun sounds more correct. "Who took the last cookie?" should sound better as "I took the cookie." than "Me took the cookie." In the same way, a question such as "Kelly Smith invited me to the prom," should be rendered as "Whom did Kelly Smith invite to the prom?" instead of "Who did Kelly Smith invite to the prom?" Subjects are matched with subjects, and direct objects are matched with direct objects.