CO line emission from circumstellar envelopes