function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rajahmrajahm 

Wants to retrieve logged-in user's e-mail address

Hello,

{!$User.Email}

I want to retrieve logged-in user's e-mail address. It is very easy to get in Visual Force Page using { !$User.Email}. How can we get this information into APEX code. I am sure that I am missing something here.

 

Any assistance is appreciated.

Thanks

Raja

Best Answer chosen by Admin (Salesforce Developers) 
Ritesh AswaneyRitesh Aswaney

 

User u = [Select Id, Name, Email from User where Id = :UserInfo.getUserId()];
System.debug(u.Email);