Class User
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
کاربر نمایش یک کاربر، مناسب برای اسکریپت نویسی.
روش ها
روش | نوع برگشت | شرح مختصر |
---|
get Email() | String | آدرس ایمیل کاربر را در صورت وجود دریافت می کند. |
مستندات دقیق
get Email()
آدرس ایمیل کاربر را در صورت وجود دریافت می کند. اگر سیاست های امنیتی اجازه دسترسی به آدرس ایمیل کاربر را نمی دهد، این روش یک رشته خالی را برمی گرداند. شرایطی که در آن آدرس ایمیل در دسترس است متفاوت است: برای مثال، آدرس ایمیل کاربر در هیچ زمینهای که اجازه میدهد یک اسکریپت بدون مجوز آن کاربر اجرا شود، مانند یک راهانداز ساده on Open(e)
یا on Edit(e)
در دسترس نیست. ، یک تابع سفارشی در Google Sheets یا یک برنامه وب استقرار یافته برای "اجرا به عنوان من" (یعنی توسط توسعه دهنده به جای کاربر مجاز شده است). با این حال، اگر توسعهدهنده خود اسکریپت را اجرا کند یا به همان دامنه Google Workspace با کاربر تعلق داشته باشد، این محدودیتها معمولا اعمال نمیشوند.
// Log the email address of the person running the script.
Logger.log(Session.getActiveUser().getEmail());
بازگشت
String
- آدرس ایمیل کاربر، یا اگر سیاست های امنیتی اجازه دسترسی به آدرس ایمیل کاربر را نمی دهد، یک رشته خالی است.
روش های منسوخ شده
get User Login Id()
منسوخ شده است. از 24 ژوئن 2013، با get Email()
جایگزین شد.
آدرس ایمیل کاربر را دریافت می کند.
// Log the email address of the person running the script.
Logger.log(Session.getActiveUser().getUserLoginId());
بازگشت
String
- آدرس ایمیل کاربر.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[[["\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."]]