The sun emits photons at all wavelengths, including X-rays. These X-rays travel to the surface of Mercury, and atoms on the surface absorb them. An electron is excited from an inner energy level as the atom absorbs the X-ray. This process leaves the atom in an excited state with vacancy in its electronic structure. In order for the atom to return to its ground state, another electron falls into the inner energy level and a fluorescence X-ray is released with an energy that is characteristic of the type of atom that has undergone the excitation. Therefore, by recording the X-ray spectrum you can work out the elements that make up Mercury’s surface.