Many-body Green's function theory for the magnetic reorientation of thin ferromagnetic films