How do I get the public email address of a User through Graph API? How does the code look like in C#?
Important Criteria for this functionality is: The User isn't logged in or Authorized by Azure AD, Graph API...
I want to search for a user by First and Last Name. Is this possible?
The code below returns the Email of a User filtered by DisplayName:
[HttpGet, Route("GetEmail")]
public async Task<ActionResult> GetEmail([FromForm] string filter)
{
var users = await graphClient.Users
.Request()
.Filter("startswith(displayName,'" + filter.ToString() + "')")
.Select(e => new {
e.Mail,
e.DisplayName,
e.GivenName
}).GetAsync();
if (users.Count > 0)
return Ok(users[0].Mail);
else
return BadRequest("No user found");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.