إدارة إعدادات العطلة
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يمكنك استخدام الإعدادات
لضبط الردّ التلقائي المجدوَل لحساب.
للحصول على معلومات حول كيفية
الحصول على أو
تحديث
البرنامج، يُرجى الاطّلاع على مرجع الإعدادات.
ضبط الرد التلقائي
تتطلّب الردود التلقائية موضوعًا ونصًا للرد، إما بتنسيق HTML أو نص عادي. ويمكن تفعيلها لأجل غير مسمى أو لفترة زمنية محدّدة. يمكنك أيضًا حصر الردود التلقائية على جهات الاتصال المعروفة أو أعضاء النطاق.
مثال على إعداد ردّ تلقائي لمدة زمنية محدّدة، مع حصر الردود على المستخدمين في النطاق نفسه:
لإيقاف الرد التلقائي، عدِّل المورد واضبط enableAutoReply
على false
. في حال ضبط endTime
، سيتم إيقاف الردّ التلقائي تلقائيًا
بعد انقضاء الوقت المحدّد.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-08-29 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-29 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Managing Vacation Settings\n\nYou can use [Settings](/workspace/gmail/api/v1/reference/users/settings) to\nconfigure scheduled [auto-reply](https://support.google.com/mail/answer/25922) for an account.\n\nFor information on how to\n[get](/workspace/gmail/api/v1/reference/users/settings/getVacation) or\n[update](/workspace/gmail/api/v1/reference/users/settings/updateVacation),\nsee the [Settings reference](/workspace/gmail/api/v1/reference/users/settings).\n\nConfiguring auto-reply\n----------------------\n\nAuto-reply requires a response subject and body, either HTML or plain text. It\ncan be enabled indefinitely, or limited to a defined period of time. You can\nalso restrict auto-reply to known contacts or domain members.\n\nExample of setting an auto-reply for a fixed period of time, restricting replies\nto users in the same domain: \n\n### Java\n\ngmail/snippets/src/main/java/EnableAutoReply.java \n[View on GitHub](https://github.com/googleworkspace/java-samples/blob/main/gmail/snippets/src/main/java/EnableAutoReply.java) \n\n```java\nimport com.google.api.client.googleapis.json.GoogleJsonError;\nimport com.google.api.client.googleapis.json.GoogleJsonResponseException;\nimport com.google.api.client.http.HttpRequestInitializer;\nimport com.google.api.client.http.javanet.NetHttpTransport;\nimport com.google.api.client.json.gson.GsonFactory;\nimport com.google.api.services.gmail.Gmail;\nimport com.google.api.services.gmail.GmailScopes;\nimport com.google.api.services.gmail.model.VacationSettings;\nimport com.google.auth.http.HttpCredentialsAdapter;\nimport com.google.auth.oauth2.GoogleCredentials;\nimport java.io.IOException;\nimport java.time.LocalDateTime;\nimport java.time.ZoneOffset;\nimport java.time.ZonedDateTime;\n\n/* Class to demonstrate the use of Gmail Enable Auto Reply API*/\npublic class EnableAutoReply {\n /**\n * Enables the auto reply\n *\n * @return the reply message and response metadata.\n * @throws IOException - if service account credentials file not found.\n */\n public static VacationSettings autoReply() throws IOException {\n /* Load pre-authorized user credentials from the environment.\n TODO(developer) - See https://developers.google.com/identity for\n guides on implementing OAuth2 for your application. */\n GoogleCredentials credentials = GoogleCredentials.getApplicationDefault()\n .createScoped(GmailScopes.GMAIL_SETTINGS_BASIC);\n HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(credentials);\n\n // Create the gmail API client\n Gmail service = new Gmail.Builder(new NetHttpTransport(),\n GsonFactory.getDefaultInstance(),\n requestInitializer)\n .setApplicationName(\"Gmail samples\")\n .build();\n\n try {\n // Enable auto reply by restricting domain with start time and end time\n VacationSettings vacationSettings = new VacationSettings()\n .setEnableAutoReply(true)\n .setResponseBodyHtml(\n \"I am on vacation and will reply when I am back in the office. Thanks!\")\n .setRestrictToDomain(true)\n .setStartTime(LocalDateTime.now()\n .toEpochSecond(ZoneOffset.from(ZonedDateTime.now())) * 1000)\n .setEndTime(LocalDateTime.now().plusDays(7)\n .toEpochSecond(ZoneOffset.from(ZonedDateTime.now())) * 1000);\n\n VacationSettings response = service.users().settings()\n .updateVacation(\"me\", vacationSettings).execute();\n // Prints the auto-reply response body\n System.out.println(\"Enabled auto reply with message : \" + response.getResponseBodyHtml());\n return response;\n } catch (GoogleJsonResponseException e) {\n // TODO(developer) - handle error appropriately\n GoogleJsonError error = e.getDetails();\n if (error.getCode() == 403) {\n System.err.println(\"Unable to enable auto reply: \" + e.getDetails());\n } else {\n throw e;\n }\n }\n return null;\n }\n}\n```\n\n### Python\n\ngmail/snippet/settings snippets/enable_auto_reply.py \n[View on GitHub](https://github.com/googleworkspace/python-samples/blob/main/gmail/snippet/settings snippets/enable_auto_reply.py) \n\n```python\nfrom datetime import datetime, timedelta\n\nimport google.auth\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\nfrom numpy import long\n\n\ndef enable_auto_reply():\n \"\"\"Enable auto reply.\n Returns:Draft object, including reply message and response meta data.\n\n Load pre-authorized user credentials from the environment.\n TODO(developer) - See https://developers.google.com/identity\n for guides on implementing OAuth2 for the application.\n \"\"\"\n creds, _ = google.auth.default()\n\n try:\n # create gmail api client\n service = build(\"gmail\", \"v1\", credentials=creds)\n\n epoch = datetime.utcfromtimestamp(0)\n now = datetime.now()\n start_time = (now - epoch).total_seconds() * 1000\n end_time = (now + timedelta(days=7) - epoch).total_seconds() * 1000\n vacation_settings = {\n \"enableAutoReply\": True,\n \"responseBodyHtml\": (\n \"I am on vacation and will reply when I am \"\n \"back in the office. Thanks!\"\n ),\n \"restrictToDomain\": True,\n \"startTime\": long(start_time),\n \"endTime\": long(end_time),\n }\n\n # pylint: disable=E1101\n response = (\n service.users()\n .settings()\n .updateVacation(userId=\"me\", body=vacation_settings)\n .execute()\n )\n print(f\"Enabled AutoReply with message: {response.get('responseBodyHtml')}\")\n\n except HttpError as error:\n print(f\"An error occurred: {error}\")\n response = None\n\n return response\n\n\nif __name__ == \"__main__\":\n enable_auto_reply()\n```\n\nTo disable auto-reply, update the resource and set `enableAutoReply` to\n`false`. If an `endTime` is configured, auto-reply will automatically disable\nonce the specified time has passed."]]