Class User

  • TheUser object represents a user and is suitable for scripting.

  • ThegetEmail() method retrieves the user's email address if available, but may return a blank string due to security policies or execution context.

  • ThegetUserLoginId() method is deprecated and has been replaced bygetEmail().

User

Representation of a user, suitable for scripting.

Methods

MethodReturn typeBrief description
getEmail()StringGets the user's email address, if available.

Deprecated methods

MethodReturn typeBrief description
getUserLoginId()StringGets the user's email address.

Detailed documentation

getEmail()

Gets the user's email address, if available. If security policies do not allow access to theuser's email address, this method returns a blank string. The circumstances in which the emailaddress is available vary: for example, the user's email address is not available in anycontext that allows a script to run without that user's authorization, like a simpleonOpen(e) oronEdit(e) trigger, a custom function in Google Sheets, or a web appdeployed to "execute as me" (that is, authorized by the developer instead of the user).However, these restrictions generally do not apply if the developer runs the script themselvesor belongs to the same Google Workspace domain as the user.

// Log the email address of the person running the script.Logger.log(Session.getActiveUser().getEmail());

Return

String — The user's email's address, or a blank string if security policies do not allow access to the user's email address.

Deprecated methods

getUserLoginId()

Deprecated. As of June 24, 2013, replaced bygetEmail().

Gets the user's email address.

// Log the email address of the person running the script.Logger.log(Session.getActiveUser().getUserLoginId());

Return

String — The user's email's address.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.