There is some instances that users have different userprincipalname vs their actual email due to an alias was used for some users. Because of this the following provide different values:
- User().Mail
- Office365Users.MyProfileV2().mail
I would recommend to factor in this scenarios to use the second as this provide coverage on users with alias on their account