Although most melodies can be harmonized using only chords I, IV and V, it is also common to use one or more of the remaining chords ( II, III, VI and VII ) to create a different feeling. These other chords are called secondary chords. As with primary chords, the secondary chord chosen for the harmony in any given bar should contain the melody note which occurs on the first or third beat of that bar (wherever the chord changes). Here is a simple melody in the key of C harmonized with chords I, IV and V.
In order to re-harmonize a melody, you need to know all the chords which contain each note. The following diagram shows all seven scale tone chords in the key of C. Notice that each note of the scale is contained in three different chords; e.g., the note C is the root of chord I (C), the 3rd of VI (Am) and the 5th of IV (F).
Here is the same melody harmonized with a mixture of primary and secondary chords. Notice how the different harmony changes the feeling of the melody as well.
The table of scale tone chords just shown can be applied to any key. The easiest way to transpose any melody or chord is to think in degrees rather than note names. Here is a numbered version of the table which applies to all keys. In time, you should memorize this as it will make harmonizing any melody a lot quicker and easier.
By using this table, it is easy to transpose both melody and chords to any other key. Here is the previous example transposed to the key of Ab major. Learn it in this key and then transpose it to all the other keys. Make a habit of playing everything you know in all keys. As with everything else, the more you do it, the easier it gets.