Exact calculation of the Doppler shift produced by cosmic strings