The role of the medium in long-range electron transfer