// Logs the address for the 'Home Address' field for contact 'John Doe'.// Can be used similarly for other fields that contain addresses.constcontacts=ContactsApp.getContactsByName('John Doe');consthomeAddress=contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);Logger.log(homeAddress[0].getAddress());
Cầu thủ trả bóng
String – địa chỉ dưới dạng chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
https://www.google.com/m8/feeds
getLabel()
Lấy nhãn cho trường này. Đây có thể là Trường, ExtendedField hoặc Chuỗi.
// Logs the label for all the address fields associated with contact// 'John Doe'. This method can be similarly called for any field that has// a label.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();for(leti=0;i < addressFields.length;i++){Logger.log(addressFields[i].getLabel());}
Cầu thủ trả bóng
Object – nhãn cho trường này
Ủy quyền
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
https://www.google.com/m8/feeds
isPrimary()
Xác định xem đây có phải là giá trị trường chính hay không.
// Logs whether or not the first address field associated with contact// 'John Doe' is labeled as primary. This method can be similarly called// for any field.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();Logger.log(addressFields[0].isPrimary());
Cầu thủ trả bóng
Boolean – liệu đây có phải là phương thức chính không
Ủy quyền
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
https://www.google.com/m8/feeds
setAddress(address)
Đặt địa chỉ của trường này.
// Sets the address for the 'Home Address' field for contact 'John Doe'.// Can be used similarly for other fields that contain addresses.constcontacts=ContactsApp.getContactsByName('John Doe');consthomeAddress=contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);homeAddress[0].setAddress('123 Main St, Raleigh, NC, 27601');
Tham số
Tên
Loại
Mô tả
address
String
địa chỉ mới
Cầu thủ trả bóng
EmailField – trường này hữu ích cho việc tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
https://www.google.com/m8/feeds
setAsPrimary()
Đặt trường này thành chính.
// Sets the first address field associated with contact 'John Doe'// as primary. This method can be similarly called for any field.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();addressFields[0].setAsPrimary();
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
https://www.google.com/m8/feeds
setLabel(field)
Đặt nhãn của trường này.
// Sets the label to 'Work' for the first address field associated// with contact 'John Doe'. This method can be similarly called for any// field that has a label.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();addressFields[0].setLabel(ContactsApp.Field.WORK_ADDRESS);
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
https://www.google.com/m8/feeds
setLabel(label)
Đặt nhãn của trường này.
// Sets the label to 'Apartment' for the first address field associated// with contact 'John Doe'. This method can be similarly called for any// field that has a label.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();addressFields[0].setLabel('Apartment');
Tham số
Tên
Loại
Mô tả
label
String
nhãn mới cho trường này
Cầu thủ trả bóng
EmailField – trường này hữu ích cho việc tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
https://www.google.com/m8/feeds
Các phương thức ngừng hoạt động
deleteEmailField()
Không dùng nữa. Hàm này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Xoá địa chỉ email này khỏi mục Liên hệ.
// Retrieves and deletes the work email address for contact 'John Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constworkEmail=contacts[0].getEmails(ContactsApp.Field.WORK_EMAIL);workEmail[0].deleteEmailField();
Ủy quyền
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
https://www.google.com/m8/feeds
getDisplayName()
Không dùng nữa. Hàm này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Trả về tên hiển thị cho địa chỉ email này.
// Logs the display name for the work email address for contact 'John Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constworkEmail=contacts[0].getEmails(ContactsApp.Field.WORK_EMAIL);Logger.log(workEmail[0].getDisplayName());
Cầu thủ trả bóng
String – tên hiển thị của email này
Ủy quyền
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
https://www.google.com/m8/feeds
setDisplayName(name)
Không dùng nữa. Hàm này không còn được dùng nữa và không nên được sử dụng trong các tập lệnh mới.
Đặt tên hiển thị cho địa chỉ email này.
// Sets the display name to 'Doe, John' for the work email address for contact// 'John Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constworkEmail=contacts[0].getEmails(ContactsApp.Field.WORK_EMAIL);workEmail[0].setDisplayName('Doe, John');
Tham số
Tên
Loại
Mô tả
name
String
tên hiển thị mới cho địa chỉ email này
Cầu thủ trả bóng
EmailField – trường email này hữu ích cho việc tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003eEmailField is deprecated and the People API advanced service should be used instead.\u003c/p\u003e\n"],["\u003cp\u003eRepresents an email field within a Contact, offering methods to manage its address, label, and primary status.\u003c/p\u003e\n"],["\u003cp\u003eProvides methods like \u003ccode\u003egetAddress()\u003c/code\u003e, \u003ccode\u003esetLabel()\u003c/code\u003e, and \u003ccode\u003eisPrimary()\u003c/code\u003e to interact with email field properties.\u003c/p\u003e\n"],["\u003cp\u003eIncludes deprecated methods such as \u003ccode\u003edeleteEmailField()\u003c/code\u003e, \u003ccode\u003egetDisplayName()\u003c/code\u003e, and \u003ccode\u003esetDisplayName()\u003c/code\u003e which should be avoided in new scripts.\u003c/p\u003e\n"]]],[],null,["# Class EmailField\n\nEmailField\n\n\n**Deprecated.** Instead, use the [People API advanced\nservice](/apps-script/advanced/people)\n\nAn email field in a Contact. \n\n### Methods\n\n| Method | Return type | Brief description |\n|--------------------------------------------|-----------------|-----------------------------------------------|\n| [getAddress()](#getAddress()) | `String` | Get the address for this field. |\n| [getLabel()](#getLabel()) | `Object` | Gets the label for this field. |\n| [isPrimary()](#isPrimary()) | `Boolean` | Gets whether this is the primary field value. |\n| [setAddress(address)](#setAddress(String)) | [EmailField](#) | Sets the address of this field. |\n| [setAsPrimary()](#setAsPrimary()) | [EmailField](#) | Sets this field to primary. |\n| [setLabel(field)](#setLabel(Field)) | [EmailField](#) | Sets the label of this field. |\n| [setLabel(label)](#setLabel(String)) | [EmailField](#) | Sets the label of this field. |\n\n### Deprecated methods\n\n| Method | Return type | Brief description |\n|-------------------------------------------------|-----------------|--------------------------------------------------|\n| [deleteEmailField()](#deleteEmailField()) | `void` | Deletes this email address from the Contact. |\n| [getDisplayName()](#getDisplayName()) | `String` | Returns the display name for this email address. |\n| [setDisplayName(name)](#setDisplayName(String)) | [EmailField](#) | Sets the display name for this email address. |\n\nDetailed documentation\n----------------------\n\n### `get``Address()`\n\nGet the address for this field.\n\n```javascript\n// Logs the address for the 'Home Address' field for contact 'John Doe'.\n// Can be used similarly for other fields that contain addresses.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst homeAddress = contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);\nLogger.log(homeAddress[0].getAddress());\n```\n\n#### Return\n\n\n`String` --- the address as a string\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n### `get``Label()`\n\nGets the label for this field. This may be a Field, ExtendedField, or a String.\n\n```javascript\n// Logs the label for all the address fields associated with contact\n// 'John Doe'. This method can be similarly called for any field that has\n// a label.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\nfor (let i = 0; i \u003c addressFields.length; i++) {\n Logger.log(addressFields[i].getLabel());\n}\n```\n\n#### Return\n\n\n`Object` --- the label for this field\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n### `is``Primary()`\n\nGets whether this is the primary field value.\n\n```javascript\n// Logs whether or not the first address field associated with contact\n// 'John Doe' is labeled as primary. This method can be similarly called\n// for any field.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\nLogger.log(addressFields[0].isPrimary());\n```\n\n#### Return\n\n\n`Boolean` --- whether this is primary\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n### `set``Address(address)`\n\nSets the address of this field.\n\n```javascript\n// Sets the address for the 'Home Address' field for contact 'John Doe'.\n// Can be used similarly for other fields that contain addresses.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst homeAddress = contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);\nhomeAddress[0].setAddress('123 Main St, Raleigh, NC, 27601');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------|----------|-----------------|\n| `address` | `String` | the new address |\n\n#### Return\n\n\n[EmailField](#) --- this field, useful for chaining\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n### `set``As``Primary()`\n\nSets this field to primary.\n\n```javascript\n// Sets the first address field associated with contact 'John Doe'\n// as primary. This method can be similarly called for any field.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\naddressFields[0].setAsPrimary();\n```\n\n#### Return\n\n\n[EmailField](#) --- this FieldValue for chaining\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n### `set``Label(field)`\n\nSets the label of this field.\n\n```javascript\n// Sets the label to 'Work' for the first address field associated\n// with contact 'John Doe'. This method can be similarly called for any\n// field that has a label.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\naddressFields[0].setLabel(ContactsApp.Field.WORK_ADDRESS);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|------------------------------------------------|------------------------|\n| `field` | [Field](/apps-script/reference/contacts/field) | the new standard label |\n\n#### Return\n\n\n[EmailField](#) --- this FieldValue for chaining\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n### `set``Label(label)`\n\nSets the label of this field.\n\n```javascript\n// Sets the label to 'Apartment' for the first address field associated\n// with contact 'John Doe'. This method can be similarly called for any\n// field that has a label.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\naddressFields[0].setLabel('Apartment');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|----------|------------------------------|\n| `label` | `String` | the new label for this field |\n\n#### Return\n\n\n[EmailField](#) --- this field, useful for chaining\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\nDeprecated methods\n------------------\n\n### `delete``Email``Field()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nDeletes this email address from the Contact.\n\n```javascript\n// Retrieves and deletes the work email address for contact 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst workEmail = contacts[0].getEmails(ContactsApp.Field.WORK_EMAIL);\nworkEmail[0].deleteEmailField();\n```\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n### `get``Display``Name()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nReturns the display name for this email address.\n\n```javascript\n// Logs the display name for the work email address for contact 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst workEmail = contacts[0].getEmails(ContactsApp.Field.WORK_EMAIL);\nLogger.log(workEmail[0].getDisplayName());\n```\n\n#### Return\n\n\n`String` --- the display name for this email\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n### `set``Display``Name(name)`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nSets the display name for this email address.\n\n```javascript\n// Sets the display name to 'Doe, John' for the work email address for contact\n// 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst workEmail = contacts[0].getEmails(ContactsApp.Field.WORK_EMAIL);\nworkEmail[0].setDisplayName('Doe, John');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|---------------------------------------------|\n| `name` | `String` | the new display name for this email address |\n\n#### Return\n\n\n[EmailField](#) --- this email field, useful for chaining\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`"]]