Hi @Sherazad Ahmed ,
According to my research and testing , we can use jQuery Ajax with REST API to get email address.
I tried to create a list with the 'username' column and then get the email address from username using RESI API;
Here is an example you can refer to, hope it can help you :
<div id="UserWithEmail"></div>
<script src="https://code.jquery.com/jquery-2.2.4.js" type="text/javascript"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script src="https://MyServer/sites/SiteCollection/style library/js/ScriptFile.js"></script>
<script src="//code.jquery.com/jquery-3.1.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var listname = "user";
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listname + "')/items?$select=username";
$.ajax({
url: url,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
var items = data.d.results;
var siteUsers=getSiteUsers();
var table="<table border='1'><th>User Name</th><th>User Email</th>";
for(var i = 0; i < items.length;i++) {
table+="<tr><td>"+items[i].username+"</td><td>"
for(var j = 0; j < siteUsers.length;j++) {
if(items[i].username==siteUsers[j].Title){
table+=siteUsers[j].Email;
}
}
table+="</td></tr>"
}
table+="</table>";
$("#UserWithEmail").html(table);
},
error: function (data) {
}
});
});
function getSiteUsers(){
var results;
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/siteusers?$select=Title,Email";
$.ajax({
url: url,
method: "GET",
async: false,
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
results = data.d.results;
},
error: function (data) {
}
});
return results;
}
</script>
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.