Class User
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
메서드
메서드 | 반환 유형 | 간략한 설명 |
getEmail() | String | 가능한 경우 사용자의 이메일 주소를 가져옵니다. |
자세한 문서
getEmail()
가능한 경우 사용자의 이메일 주소를 가져옵니다. 보안 정책에서 사용자의 이메일 주소에 대한 액세스를 허용하지 않으면 이 메서드는 빈 문자열을 반환합니다. 이메일 주소를 사용할 수 있는 상황은 다양합니다. 예를 들어 간단한 onOpen(e)
또는 onEdit(e)
트리거, Google Sheets의 맞춤 함수, '나로 실행' (즉, 사용자 대신 개발자가 승인)하도록 배포된 웹 앱과 같이 사용자의 승인 없이 스크립트를 실행할 수 있는 컨텍스트에서는 사용자의 이메일 주소를 사용할 수 없습니다.
그러나 개발자가 직접 스크립트를 실행하거나 사용자와 동일한 Google Workspace 도메인에 속해 있는 경우에는 일반적으로 이러한 제한사항이 적용되지 않습니다.
// Log the email address of the person running the script.
Logger.log(Session.getActiveUser().getEmail());
리턴
String
: 사용자의 이메일 주소 또는 보안 정책에서 사용자의 이메일 주소에 대한 액세스를 허용하지 않는 경우 빈 문자열입니다.
지원 중단된 메서드
getUserLoginId()
지원 중단되었습니다. 2013년 6월 24일부터 getEmail()
로 대체되었습니다.
사용자의 이메일 주소를 가져옵니다.
// Log the email address of the person running the script.
Logger.log(Session.getActiveUser().getUserLoginId());
리턴
String
: 사용자의 이메일 주소입니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003eRepresents a user for scripting purposes, providing methods to access user information.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetEmail()\u003c/code\u003e retrieves the user's email address if permitted by security policies, returning a blank string otherwise.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003egetUserLoginId()\u003c/code\u003e is deprecated and replaced by \u003ccode\u003egetEmail()\u003c/code\u003e for retrieving the user's email address.\u003c/p\u003e\n"],["\u003cp\u003eAccess to the user's email address might be restricted in certain contexts due to security considerations, such as unauthorized script execution.\u003c/p\u003e\n"]]],[],null,["# Class User\n\nUser\n\nRepresentation of a user, suitable for scripting. \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------|-------------|----------------------------------------------|\n| [getEmail()](#getEmail()) | `String` | Gets the user's email address, if available. |\n\n### Deprecated methods\n\n| Method | Return type | Brief description |\n|---------------------------------------|-------------|--------------------------------|\n| [getUserLoginId()](#getUserLoginId()) | `String` | Gets the user's email address. |\n\nDetailed documentation\n----------------------\n\n### `get``Email()`\n\nGets the user's email address, if available. If security policies do not allow access to the\nuser's email address, this method returns a blank string. The circumstances in which the email\naddress is available vary: for example, the user's email address is not available in any\ncontext that allows a script to run without that user's authorization, like a simple `on``Open(e)` or `on``Edit(e)` trigger, a custom function in Google Sheets, or a web app\ndeployed to \"execute as me\" (that is, authorized by the developer instead of the user).\nHowever, these restrictions generally do not apply if the developer runs the script themselves\nor belongs to the same Google Workspace domain as the user.\n\n```javascript\n// Log the email address of the person running the script.\nLogger.log(Session.getActiveUser().getEmail());\n```\n\n#### Return\n\n\n`String` --- The user's email's address, or a blank string if security policies do not allow access\nto the user's email address.\n\nDeprecated methods\n------------------\n\n### `get``User``Login``Id()`\n\n\n**Deprecated.** As of June 24, 2013, replaced by [getEmail()](#getEmail()).\n\nGets the user's email address.\n\n```javascript\n// Log the email address of the person running the script.\nLogger.log(Session.getActiveUser().getUserLoginId());\n```\n\n#### Return\n\n\n`String` --- The user's email's address."]]