Field-induced magnetic dipolar interaction for general boundary conditions