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
Arunkumar KathirArunkumar Kathir 

Current user mail ID in apex trigger

HI,

 

How to get current user's email ID in apex trigger? Please help.

 

 

Thanks,

Arunkumar

Best Answer chosen by Admin (Salesforce Developers) 
SFDC-SDSFDC-SD

You can use the code below:

User current_user=[SELECT Email FROM User WHERE Id= :UserInfo.getUserId()] ;

 c.Contact_Email__c = current_user.Email;

 

There is no direct method to get User Email unlike UserId

All Answers

SFDC-SDSFDC-SD

You can use the code below:

User current_user=[SELECT Email FROM User WHERE Id= :UserInfo.getUserId()] ;

 c.Contact_Email__c = current_user.Email;

 

There is no direct method to get User Email unlike UserId

This was selected as the best answer
JamuraiJamurai
User this http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_System_UserInfo_getUserEmail.htm

getUserEmail()