A macroscopic theory for scanning optical near held microscopy is pres
ented. The theory, based upon the Rayleigh method, solves rigorously t
he electromagnetic field near a multilayer system with arbitrary one-d
imension structure on its interfaces. The method is suitable for both
s- and p-polarized incident light. It may also apply in cases where th
e resonances in the system, such as the plasmon in a metallic sample,
become important.