SP.User.email property (sp.js)
This property is not available in SharePoint Online. Gets or sets the email address of the user.
Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013
var value = SP.User.get_email ()
var value = SP.User.set_email ()
Return value
Type: String
The email address of the user.
Remarks
The value's length must be equal to or less than 255. It must not be null.
Example
The following code example gets the email address of the current user. The example also gets the user's account name.
var clientContext;
var user;
// Make sure the SharePoint script file 'sp.js' is loaded before your
// code runs.
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
function sharePointReady() {
clientContext = SP.ClientContext.get_current();
user = clientContext.get_web().get_currentUser();
clientContext.load(user);
clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
}
function onQuerySucceeded() {
alert('The email address of the current user is ' + user.get_email());
alert('The account name is ' + user.get_loginName());
}
function onQueryFailed(sender, args) {
alert('Error: ' + args.get_message());
}
REST resource endpoint
See User resource for more information.
Endpoint URI structure
http://<sitecollection>/<site>/_api/web/sitegroups(groupid)/users(loginname)/email
HTTP requests
This resource supports the following HTTP commands:
- POST
POST syntax
POST http://<sitecollection>/<site>/_api/web/sitegroups(groupid)/users(loginname)/email
GET syntax
GET http://<sitecollection>/<site>/_api/web/sitegroups(groupid)/users(loginname)/email