In a SharePoint 2013 OnPrem environment, I have an add-in that needs to get the email address of the current user, using the following code:
var clientContext = new SP.ClientContext();
user = clientContext.get_web().get_currentUser();
var email = user.get_email();
We recently discovered that new users were missing email addresses. I went to Central admin and looked up the user, but the email was registered fine.
Then I opened up PowerShell and used Get-SPUser to find the user and view the details. To my surprise, the email address was not there.
I updated the email address using Set-SPUser and everything was working again. But this workaround requires a manual step for every New user in SharePoint.
Why isn't the email address reflected in the result of Get-SPUser, when it shows up correctly in the user profile administration in Central admin..?