cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SimonTocker
Advocate I
Advocate I

User().Email display UPN value not Email

Hi,

at this point in time Im working with a company that does not use the users Email as the UPN, this is a valid approach, its allowed,  whilst it causes problems with Invites to 365 sites, it is a valid scenario.

When In powerapps,  I I use the function User().Email,  then the users UPN is displayed,   this is not the users Email, but in testing because everyone users an email address in the UPN it is easily missed in testing.

In the picture below I hid the actual text being returned,   but the label below shows the format of the companies UPN,   it would look like   

    X99999@company.com   

The users SAMAccount is the prefix and the companys actual domain is the suffix,   it looks like an email address, but isnt and isnt tied to an exchange alias either.   So it cannot be used as an email,   

The User().Email   function and property needs to get the actual AzureAD email field.

UPN.png

 

12 REPLIES 12
JimmyJams
Advocate I
Advocate I

I know @v-yuazh-msft already answered the original question, but in case you find this post dealing with looking up other user records (as opposed to the explicit user signed into the app) but have this UPN/SMTP issue then here are some code samples that will be useful.

 

Office365Users.UserProfileV2() function has .userPrincipalName property that can be used to spit out the UPN address, since some connectors and functions are only happy with it. Gallery person field example:

Office365Users.UserProfileV2(GalleryName.Selected.PersonFieldName.Email).userPrincipalName

 

There can be legitimate reasons for UPN and SMTP being different. Normally the public facing expectation is the SMTP address, so maybe that's in some data sources and you want to convert that to UPN: 

Office365Users.UserProfileV2(GalleryName.Selected.FieldNameWithSMTP.Value).userPrincipalName // though at this point you also use this start calling .displayName, .department, or other 365 profile properties

 

If you want to explicitly display the SMTP field instead of the UPN name (because that's what public facing end-users probably expect) we can also extract that with the .mail property. Another example with a person field:

Office365Users.UserProfileV2(GalleryName.Selected.PersonFieldName.Email).mail

 

I know not quite what the original post is about, but Google-fu has brought me here several times trying to resolve the UPN/SMTP thing so hope this solution helps someone.

MartinDAZN
Advocate I
Advocate I

Nearly 4 years after this was raised, it is still an issue!

 

My work around to get the true email for the current user, is as follows:

 

Office365Users.UserProfileV2(User().Email).mail

valygreavueon
New Member

My solution to extract only email address is to define a variable on Form load (new, edit, view):

 

Set(varEmail, If(IsBlankOrError(Find("#",User().Email)), User().Email, Right(User().Email, Len(User().Email)-Find("#",User().Email))));

 

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,277)