The method involves applying coating material (7) on surface (2) of recess (3) formed in substrate (1). A liquid auxiliary agent (6) is applied on substrate surface, such that recess is filled with auxiliary agent. The coating material is subsequently applied to auxiliary agent on substrate. A coating material portion in auxiliary agent is transported by coating material diffusion. The agent is subsequently separated from coating material, such that coating material on substrate surface is left behind, and coating of substrate surface including recess is formed with coating material.