Hold the chord and pick through the notes. You will create a melody on the E String while holding the D Chord.  This technique is used in many songs so it's important that you get it down.  Make sure the notes ring out.

guitar tab for the chord exercise E String Melody

A similar melody is played in the song Summer Of '69 by Bryan Adams.   This is a great repeating progression that will train your fingers.

Summer Of '69 by Bryan Adams

guitar tab for summer of 69
red guitar logo illustration