The solvent effect on the I⋯O halogen bonding in complexes of iodobenzene derivatives with formaldehyde has been investigated by systematically varying the substituents on the iodobenzene ring. Calculations have been performed at MP2 and DFT levels of theory, using the aug-cc-pVDZ basis set and the pseudopotential for iodine. Within the DFT approach, a series of the most widely used exchange-correlation functionals have been considered, comprising PBE, PBE0, B3LYP, BH&HLYP, M06-2X and M06-HF. Results obtained in diethylether and in water using the conductor-like polarizable continuum model (CPCM) have been compared with in vacuo results. Though halogen bonding distances were found to systematically shorten when moving from vacuo to diethylether and then to water, the associated interaction energies showed a decrease in absolute value, indicating that solvent has a destabilizing effect on this interaction. By comparison with MP2 results, all the considered functionals, B3LYP excepted, have been found adequate to describe halogen bonding. As far as the interaction energies are concerned, the best performance was obtained with the M06-HF functional in vacuo and the PBE functional in solution. The geometrical parameters characterizing halogen bonds were better reproduced by the M06-2X functional.