This paper proposes an efficient technique to solve the electromagnetic scattering problem, in the near zone of scatterers illuminated by external fields. The technique is based on a differential formulation of the Helmholtz equation discretized in terms of a finite element method (FEM). In order to numerically solve the problem, it is necessary to truncate the unbounded solution domain to obtain a bounded computational domain. This is usually done by defining fictitious boundaries where absorbing conditions are imposed, for example by applying the perfect matching layer (PML) approach. In this paper, these boundary conditions are expressed in an analytical form by using the Dirichlet-to-Neumann (DtN) operator. Compared to classical solutions such as PML, the proposed approach based on the DtN: (i) avoids the errors related to approximated boundary conditions; (ii) allows placing the boundary in close proximity to the scatterers, thus, reducing the solution domain to be meshed and the related computational cost; (iii) allows dealing with objects of arbitrary shapes and materials, since the shape of the boundary independent from those of the scatterers. Case-studies on problems related to the scattering from cable bundles demonstrate the accuracy and the computational advantage of the proposed technique, compared to existing ones.