Electron excitation and the optical potential in electron microscopy