web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Retrieve user profiles...
Power Apps
Answered

Retrieve user profiles from a collection of user emails

(0) ShareShare
ReportReport
Posted on by 4

I have a collection called userEmails that I have populated with every employee's company email address. I am trying to use the Office365Users connection to pull the User Profiles into a new collection called userProfiles. 

 

Currently my code is :

 

ClearCollect(
 userProfiles,
 ForAll(
 userEmails.Value,
 Office365Users.UserProfileV2(First(userEmails).Value)
 )
);

 

 I have tried UserProfile and UserProfileV2 and both ways just populate blank rows in my collection userProfiles. 

 

userEmails has 6 test email addresses in it and when I run the code, userProfiles populates to 6 rows with the correct headers for UserProfile but no data. Does anyone know the issue or a different solution to my task?

Categories:
I have the same question (0)
  • Max44 Profile Picture
    223 on at

    Will it be safe to assume that the users email address is stored in the AD? In that case you might use DirectorySearcher to query for a user.

     

     

     
  • eka24 Profile Picture
    20,925 on at

    Have you read this post:
    https://powerusers.microsoft.com/t5/Building-Power-Apps/Build-a-collection-of-user-profiles-from-O365-users-AND-a/m-p/277031

     

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @jchen1 ,

    Do you want to save user profile in a collection?

    Could you show me your collection of userEmails?

    Have you checked your emails in userEmails in your talent?

    I've made a similar test and found that you need to make a little change on your original formula.

    Here's my test for your reference:

    1)create  userEmails collection:

    ClearCollect(userEmails,["Phoebel@Wic....ft.com","Test5@W...rosoft.com"])

    4107.PNG

     2)create  userProfiles collection:

    ClearCollect(
     userProfiles,
     ForAll(
     userEmails.Value,
     Office365Users.UserProfileV2(Value)
     )
    )

    First(userEmails).Value only represents the first email in useremail collection. You just need to use fieldname Value in Office365Users.UserProfileV2 function.

    ForAll(collection,Office365Users.UserProfileV2(fieldname)) represents you will perform Office365Users.UserProfileV2(fieldname) one by one record.

     

    Then I will get a collection with user profiles.

    4108.PNG

     

     

    Best regards,

     

  • jchen1 Profile Picture
    4 on at

    @v-yutliu-msft 

    Thank you! This worked great! 

     

    My userEmails was a collection with a blank column (Result) and a column (Value) that looked just like the example you made. After changing my code to match what you had, userProfiles populated with every employee profile.

  • paulewert Profile Picture
    18 on at

    Watch out. Being that UserProfileV2 takes a "User (UPN)" parameter described as "user principal name or email id" and User().Email may not return a value which matches that returned by UserProfileV2. This is particularly true for users with multiple registered SMTP values (these can be seen using Outlook client's Address Book search and then viewing the "E-mail Addresses" tab of the contact card). Thus, this action may not work as expected if you pass in the user's email address. In our environment, the user's username portion of their email address does not always match their user principal name. (Mine does not.) Without experimentation or better documentation, it's hard to know if UserProfileV2 is taking an email address or a user principal name + domain. I side-stepped the ambiguity and simply used the user's ID as returned from Microsoft365Users.MyProfileV2({'$select':"id"}).id.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#2
11manish Profile Picture

11manish 205 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard