We aim to (1) set up simple and general analytical expressions to estimate mass-loss rates of evolved stars, and (2) from those calculate estimates for the mass-loss rates of asymptotic giant branch (AGB), red supergiant (RSG), and yellow hypergiant stars in our galactic sample. Rotationally excited lines of CO are a very robust diagnostic in the study of circumstellar envelopes (CSEs). When sampling different layers of the CSE, observations of these molecular lines lead to detailed profiles of kinetic temperature, expansion velocity, and density. A state-of-the-art, nonlocal thermal equilibrium, and co-moving frame radiative transfer code that predicts CO line intensities in the CSEs of late-type stars is used in deriving relations between stellar and molecular-line parameters, on the one hand, and mass-loss rate, on the other. We present analytical expressions for estimating the mass-loss rates of evolved stellar objects for 8 rotational transitions of the CO molecule, apply them to our extensive CO data set covering 47 stars, and compare our results to those of previous studies. Our expressions account for line saturation and resolving of the envelope, thereby allowing accurate determination of very high mass-loss rates. We argue that, for estimates based on a single rotational line, the CO(2-1) transition provides the most reliable mass-loss rate. The mass-loss rates calculated for the AGB stars range from 4x10^-8 Msun/yr up to 8x10^-5 Msun/yr. For RSGs they reach values between 2x10^-7 Msun/yr and 3x10^-4 Msun/yr. The estimates for the set of CO transitions allow time variability to be identified in the mass-loss rate. Possible mass-loss-rate variability is traced for 7 of the sample stars. We find a clear relation between the pulsation periods of the AGB stars and their derived mass-loss rates, with a levelling off at approx. 3x10^-5 Msun/yr for periods exceeding 850 days.