تحصل على عنوان البريد الإلكتروني للمستخدم، إن توفّر. إذا كانت سياسات الأمان لا تسمح بالوصول إلى عنوان البريد الإلكتروني للمستخدم، تعرض هذه الطريقة سلسلة فارغة. تختلف الظروف التي يتوفّر فيها عنوان البريد الإلكتروني: على سبيل المثال، لا يتوفّر عنوان البريد الإلكتروني للمستخدم في أي سياق يسمح بتشغيل نص برمجي بدون تفويض هذا المستخدم، مثل عامل تشغيل onOpen(e) أو onEdit(e) بسيط أو دالة مخصّصة في "جداول بيانات Google" أو تطبيق ويب تم نشره "للتنفيذ نيابةً عني" (أي أنّ المطوّر هو من أذن به بدلاً من المستخدم). ومع ذلك، لا تنطبق هذه القيود بشكل عام إذا كان المطوّر يشغّل النص البرمجي بنفسه أو كان ينتمي إلى نطاق Google Workspace نفسه الذي ينتمي إليه المستخدم.
// Log the email address of the person running the script.Logger.log(Session.getActiveUser().getEmail());
الإرجاع
String: عنوان البريد الإلكتروني للمستخدم، أو سلسلة فارغة إذا كانت سياسات الأمان لا تسمح بالوصول إلى عنوان البريد الإلكتروني للمستخدم
الطرق المتوقّفة
getUserLoginId()
تمّ إيقاف هذا العمود نهائيًا. اعتبارًا من 24 حزيران (يونيو) 2013، تم استبداله بـ getEmail().
تحصل على عنوان البريد الإلكتروني للمستخدم.
// Log the email address of the person running the script.Logger.log(Session.getActiveUser().getUserLoginId());
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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,["User\n\nRepresentation of a user, suitable for scripting. \n\nMethods\n\n| Method | Return type | Brief description |\n|---------------------------|-------------|----------------------------------------------|\n| [getEmail()](#getEmail()) | `String` | Gets the user's email address, if available. |\n\nDeprecated methods\n\n| Method | Return type | Brief description |\n|---------------------------------------|-------------|--------------------------------|\n| [getUserLoginId()](#getUserLoginId()) | `String` | Gets the user's email address. |\n\nDetailed documentation \n\n`get``Email()` \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\nReturn\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`get``User``Login``Id()` \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\nReturn\n\n\n`String` --- The user's email's address."]]