Fluctuations in the cosmic microwave background induced by cosmic strings: Methods and formalism