In the sentence:
- I sang Mary a song
The first Object, Mary, is the Indirect Object—the person that 'gets' the song. The phrase a song is the Direct Object—the thing being given. If we change the order of Mary and the song, the grammar changes:
- I sang a song to Mary.
In the example above, a song is still a Direct Object, but the preposition phrase to Mary is not an Indirect Object. We describe it as a Complement of the verb sing. [Notice that to Mary does not get the song!]
Inside this preposition phrase, the word Mary is the Complement of the preposition to. It is not an Object or Complement of the verb. It is a Complement of the preposition.
In the Original Poster's example:
He sang to himself.
The verb sang has no Objects. It only has a prepositional Complement.
As a general rule of thumb a preposition phrase will usually be a Complement of the verb (maybe a Predicative Complement, or a Locative Complement). But it will very rarely be the Direct or Indirect Object of the verb.
One test we can do to see if a phrase is a Direct Object, or perhaps an Indirect Object, is to see if we can passivise the sentence by making that phrase the Subject of a passive sentence:
- Mary was sung a song.
- *To Mary was sung a song. (ungrammatical)
- *To him was sung the song. (ungrammatical)
- *To himself was sung the song. (ungrammatical)
In the rare cases where a preposition phrase is the Object of a verb, we will usually be able to passivise it:
- We judged after Christmas to be the best time for the party.
- After Christmas was judged to be the best time for the party.