已淘汰。請改用 People API 進階服務
聯絡人中的電子郵件欄位。
方法
方法 | 傳回類型 | 簡短說明 |
---|---|---|
get | String | 取得這個欄位的地址。 |
get | Object | 取得這個欄位的標籤。 |
is | Boolean | 取得是否為主要欄位值。 |
set |
| 設定這個欄位的地址。 |
set |
| 將這個欄位設為 primary。 |
set |
| 設定這個欄位的標籤。 |
set |
| 設定這個欄位的標籤。 |
已淘汰的方法
方法 | 傳回類型 | 簡短說明 |
---|---|---|
| void | 從聯絡人中刪除這個電子郵件地址。 |
| String | 傳回這個電子郵件地址的顯示名稱。 |
|
| 設定這個電子郵件地址的顯示名稱。 |
內容詳盡的說明文件
getAddress()
取得這個欄位的地址。
// 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
getLabel()
取得這個欄位的標籤。這可能是欄位、ExtendedField 或字串。
// 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
isPrimary()
取得是否為主要欄位值。
// 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
setAddress(address)
設定這個欄位的地址。
// 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
setAsPrimary()
將這個欄位設為 primary。
// 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();
回攻員
:用於鏈結的 FieldValueEmail
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
setLabel(field)
設定這個欄位的標籤。
// 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 |
| 新的標準標籤 |
回攻員
:用於鏈結的 FieldValueEmail
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
setLabel(label)
設定這個欄位的標籤。
// 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
已淘汰的方法
deleteEmailField()
deleteEmailField()
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
從聯絡人中刪除這個電子郵件地址。
// Retrieves and deletes the work email address for contact 'John Doe' const contacts = ContactsApp.getContactsByName('John Doe'); const workEmail = contacts[0].getEmails(ContactsApp.Field.WORK_EMAIL); workEmail[0].deleteEmailField();
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
getDisplayName()
getDisplayName()
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
傳回這個電子郵件地址的顯示名稱。
// Logs the display name for the work email address for contact 'John Doe' const contacts = ContactsApp.getContactsByName('John Doe'); const workEmail = contacts[0].getEmails(ContactsApp.Field.WORK_EMAIL); Logger.log(workEmail[0].getDisplayName());
回攻員
String
:電子郵件的顯示名稱
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds
setDisplayName(name)
setDisplayName(name)
已淘汰。這個函式已淘汰,不建議在新指令碼中使用。
設定這個電子郵件地址的顯示名稱。
// Sets the display name to 'Doe, John' for the work email address for contact // 'John Doe' const contacts = ContactsApp.getContactsByName('John Doe'); const workEmail = contacts[0].getEmails(ContactsApp.Field.WORK_EMAIL); workEmail[0].setDisplayName('Doe, John');
參數
名稱 | 類型 | 說明 |
---|---|---|
name | String | 這個電子郵件地址的新顯示名稱 |
回攻員
:這個電子郵件欄位可用於鏈結Email
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.google.com/m8/feeds