已弃用。请改用 People API 高级服务
联系人中的电子邮件字段。
方法
| 方法 | 返回类型 | 简介 | 
|---|---|---|
| get | String | 获取此字段的地址。 | 
| get | Object | 获取此字段的标签。 | 
| is | Boolean | 获取这是主字段值的确切信息。 | 
| set |  | 设置此字段的地址。 | 
| set |  | 将此字段设置为主要字段。 | 
| set |  | 设置此字段的标签。 | 
| set |  | 设置此字段的标签。 | 
详细文档
get
获取此字段的地址。
// Logs the address for the 'Home Address' field for contact 'John Doe'. // Can be used similarly for other fields that contain addresses. const contacts = ContactsApp.getContactsByName('John Doe'); const homeAddress = contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS); Logger.log(homeAddress[0].getAddress());
返回
String - 地址(字符串)
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.google.com/m8/feeds
get
获取此字段的标签。这可以是 Field、ExtendedField 或 String。
// 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. const contacts = ContactsApp.getContactsByName('John Doe'); const addressFields = contacts[0].getAddresses(); for (let i = 0; i < addressFields.length; i++) { Logger.log(addressFields[i].getLabel()); }
返回
Object - 此字段的标签
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.google.com/m8/feeds
is
获取这是主字段值的标志。
// 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. const contacts = ContactsApp.getContactsByName('John Doe'); const addressFields = contacts[0].getAddresses(); Logger.log(addressFields[0].isPrimary());
返回
Boolean - 是否为主
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.google.com/m8/feeds
set
设置此字段的地址。
// Sets the address for the 'Home Address' field for contact 'John Doe'. // Can be used similarly for other fields that contain addresses. const contacts = ContactsApp.getContactsByName('John Doe'); const homeAddress = contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS); homeAddress[0].setAddress('123 Main St, Raleigh, NC, 27601');
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| address | String | 新地址 | 
返回
Email
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.google.com/m8/feeds
set
将此字段设置为主要字段。
// Sets the first address field associated with contact 'John Doe' // as primary. This method can be similarly called for any field. const contacts = ContactsApp.getContactsByName('John Doe'); const addressFields = contacts[0].getAddresses(); addressFields[0].setAsPrimary();
返回
Email
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.google.com/m8/feeds
set
设置此字段的标签。
// 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. const contacts = ContactsApp.getContactsByName('John Doe'); const addressFields = contacts[0].getAddresses(); addressFields[0].setLabel(ContactsApp.Field.WORK_ADDRESS);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| field |  | 新标准标签 | 
返回
Email
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.google.com/m8/feeds
set
设置此字段的标签。
// 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. const contacts = ContactsApp.getContactsByName('John Doe'); const addressFields = contacts[0].getAddresses(); addressFields[0].setLabel('Apartment');
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| label | String | 此字段的新标签 | 
返回
Email
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.google.com/m8/feeds