Deprecated. Instead, use the People API advanced service
This class allows users to access their own Google Contacts and create, remove, and update contacts listed therein.
Deprecated properties
Property | Type | Description |
---|---|---|
ExtendedField |
| |
Field |
| |
Gender |
| |
Month | Month | |
Priority |
| |
Sensitivity |
|
Deprecated methods
Method | Return type | Brief description |
---|---|---|
|
| Creates a new contact. |
|
| Creates a contact group with the given name |
| void | Deletes the contact. |
| void | Deletes the contact group |
|
| Finds a Contact with the given email address. |
|
| Finds a contact group of the given name. |
|
| Get all the contacts belonging to this user. |
|
| Gets a contact by the email address. |
|
| Gets the contact with this id. |
|
| Gets a contact group with the given name, or returns null if no such contact group is found. |
|
| Gets a contact group with the given id, or returns null if no such contact group is found. |
|
| Gets the complete list of the user's contact groups. |
|
| Gets all of the user's contacts. |
|
| Get contacts matching an address. |
|
| Get contacts matching an address, limited to a specific field. |
|
| Get contacts matching an address, limited to the specified custom address label. |
|
| Get contacts matching the company field. |
|
| Get contacts matching a given value in a custom field. |
|
| Get contacts matching a given month and day for a particular standard field. |
|
| Get contacts matching a given month, day, and year for a particular standard field. |
|
| Get contacts matching a given month, day, and year for a particular custom field. |
|
| Get contacts matching a given month and day for a particular custom field. |
|
| Get contacts matching an email address. |
|
| Get contacts matching an email address, limited to a specific field. |
|
| Get contacts matching an email address, limited to the specified custom email address label. |
|
| Get the contacts in a given ContactGroup. |
|
| Get contacts matching an instant messaging address. |
|
| Get contacts matching an instant messaging address, limited to a specific field. |
|
| Get contacts matching an instant messaging address, limited to the specified custom instant messaging label. |
|
| Get contacts matching the job title field. |
|
| Get contacts matching a name. |
|
| Get contacts matching a name, limited to a specific field. |
|
| Get contacts matching the notes field. |
|
| Get contacts matching a phone number. |
|
| Get contacts matching a phone number, limited to a specific field. |
|
| Get contacts matching a phone number, limited to the specified custom phone number label. |
|
| Get contacts matching a URL. |
|
| Get contacts matching a URL, limited to a specific field. |
|
| Get contacts matching a URL, limited to the specified custom URL label. |
Deprecated methods
createContact(givenName, familyName, email)
createContact(givenName, familyName, email)
Deprecated. This function is deprecated and should not be used in new scripts.
Creates a new contact.
// The code below creates a new contact with the name "John Doe" and the email address // "[email protected]". var contact = ContactsApp.createContact('John', 'Doe', '[email protected]');
Parameters
Name | Type | Description |
---|---|---|
givenName | String | the first name of the contact |
familyName | String | the last name of the contact |
email | String | the email address of the contact |
Return
— the newly created Contact objectContact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
createContactGroup(name)
createContactGroup(name)
Deprecated. This function is deprecated and should not be used in new scripts.
Creates a contact group with the given name
// The code below creates a new contact group named "Work Friends" var group = ContactsApp.createContactGroup("Work Friends");
Parameters
Name | Type | Description |
---|---|---|
name | String | the name of the new contact group |
Return
— the newly created contact groupContactGroup
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
deleteContact(contact)
deleteContact(contact)
Deprecated. This function is deprecated and should not be used in new scripts.
Deletes the contact.
// The code below retrieves a contact with the email address "[email protected]" // and then deletes that contact. var contact = ContactsApp.getContact('[email protected]'); ContactsApp.deleteContact(contact);
Parameters
Name | Type | Description |
---|---|---|
contact |
| the contact to be deleted |
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
deleteContactGroup(group)
deleteContactGroup(group)
Deprecated. This function is deprecated and should not be used in new scripts.
Deletes the contact group
// The code below creates deletes the contact group named "Work Friends" var group = ContactsApp.getContactGroup("Work Friends"); ContactsApp.deleteContactGroup(group);
Parameters
Name | Type | Description |
---|---|---|
group |
| the contact group to delete |
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
findByEmailAddress(email)
findByEmailAddress(email)
Deprecated. This function is deprecated and should not be used in new scripts.
Finds a Contact with the given email address.
Parameters
Name | Type | Description |
---|---|---|
email | String | the email address of the contact to be found |
Return
— the Contact containing that email addressContact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
findContactGroup(name)
findContactGroup(name)
Deprecated. This function is deprecated and should not be used in new scripts.
Finds a contact group of the given name.
Parameters
Name | Type | Description |
---|---|---|
name | String | the name of the contact group to find |
Return
— the contact group matching the given nameContactGroup
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
getAllContacts()
getAllContacts()
Deprecated. This function is deprecated and should not be used in new scripts.
Get all the contacts belonging to this user.
Return
— all the contacts for this userContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
getContact(emailAddress)
getContact(emailAddress)
Deprecated. This function is deprecated and should not be used in new scripts.
Gets a contact by the email address.
If multiple contacts share the same email address, the method favors those contacts who have marked the email address as primary; if none of the contacts had the email address marked as primary or multiple contacts had the email address marked as primary, then it returns the first result in the sorted contacts order.
// The code below retrieves a contact with the email address "[email protected]". var contact = ContactsApp.getContact('[email protected]');
Parameters
Name | Type | Description |
---|---|---|
emailAddress | String | the email address of the contact |
Return
— the contact containing that email addressContact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactById(id)
getContactById(id)
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the contact with this id.
// The code below retrieves the contact with the id // "http://www.google.com/m8/feeds/contacts/john.doe%40example.com/base/7c86afde08d34ca5" var id = 'http://www.google.com/m8/feeds/contacts/john.doe%40example.com/base/7c86afde08d34c'; var contact = ContactApp.getContactById(id);
Parameters
Name | Type | Description |
---|---|---|
id | String | the id of the contact to retrieve |
Return
— the matching contact or nullContact
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactGroup(name)
getContactGroup(name)
Deprecated. This function is deprecated and should not be used in new scripts.
Gets a contact group with the given name, or returns null if no such contact group is found.
// The code below returns the contact group with the name "Work Friends" var group = ContactsApp.getContactGroup('Work Friends');
Parameters
Name | Type | Description |
---|---|---|
name | String | the name of the contact group to match |
Return
— the matching contact group or null if no matching contact group is foundContactGroup
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactGroupById(id)
getContactGroupById(id)
Deprecated. This function is deprecated and should not be used in new scripts.
Gets a contact group with the given id, or returns null if no such contact group is found.
// The code below returns the contact group with the id // "http://www.google.com/m8/feeds/groups/john.doe%40example.com/base/54eefbb093fdecb" var id = "http://www.google.com/m8/feeds/groups/john.doe%40example.com/base/54eefbb093fdecb"; var group = ContactsApp.getContactGroupById(id);
Parameters
Name | Type | Description |
---|---|---|
id | String | the id of the contact group to match |
Return
— the matching contact group or null if no matching contact group is foundContactGroup
See also
getContactGroups()
getContactGroups()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets the complete list of the user's contact groups.
A user can have a list of Contacts, and potentially a list of Contact Groups also. Each Contact Group can contain Contacts. This method returns a list of all the Contact Groups.
// The retrieves all the contract groups for the user and then logs the group name of each // contact group. var groups = ContactsApp.getContactGroups(); for (var i = 0; i < groups.length; i++) { Logger.log(groups[i].getName()); }
Return
— an array of the user's contact groupsContactGroup[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContacts()
getContacts()
Deprecated. This function is deprecated and should not be used in new scripts.
Gets all of the user's contacts.
// The code below will retrieve all the user's contacts var contacts = ContactsApp.getContacts();
Return
— an array of all the user's contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByAddress(query)
getContactsByAddress(query)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching an address.
// The code below returns an array of contacts where the contact's address contains // "San Francisco'. var contacts = ContactsApp.getContactsByAddress('San Francisco');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's addresses |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByAddress(query, label)
getContactsByAddress(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching an address, limited to a specific field.
// The code below returns an array of contacts where the contact's address contains // "San Francisco" in the Home address field. var contacts = ContactsApp.getContactsByAddress('San Francisco', ContactsApp.Field.HOME_ADDRESS);
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's addresses |
label |
| the field to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByAddress(query, label)
getContactsByAddress(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching an address, limited to the specified custom address label.
// The code below returns an array of contacts where the contact's address contains // "San Francisco" in a custom address label (created by the user) called // "vacation". var contacts = ContactsApp.getContactsByAddress('San Francisco', 'vacation');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's addresses with the specified custom address label |
label | String | the custom address label to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByCompany(query)
getContactsByCompany(query)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching the company field.
// The code below returns an array of contacts where the contact's company field // contains "Google". var contacts = ContactsApp.getContactsByCompany('Google');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's company field |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByCustomField(query, label)
getContactsByCustomField(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a given value in a custom field.
The custom field can be specified by a String or as one of the ContactsApp.ExtendedField values.
// The code below returns an array of contacts where the contact's custom field // named "Favorite Sport" contains "tennis". var contacts = ContactsApp.getContactsByCustomField('tennis', 'Favorite Sport');
Parameters
Name | Type | Description |
---|---|---|
query | Object | the string to search for in contact's custom field |
label |
| the custom field to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByDate(month, day, label)
getContactsByDate(month, day, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a given month and day for a particular standard field.
// The code below returns an array of contacts where the contact's "Birthday" field // contains April for the month and 19 for the day. var contacts = ContactsApp.getContactsByDate(ContactsApp.Month.APRIL, 19, ContactsApp.Field.BIRTHDAY);
Parameters
Name | Type | Description |
---|---|---|
month | Month | the month to match, as one of the values from ContactsApp.Month |
day | Integer | the day to match |
label |
| the field to search within, from ContactsApp.Field |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByDate(month, day, year, label)
getContactsByDate(month, day, year, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a given month, day, and year for a particular standard field.
// The code below returns an array of contacts where the contact's "Birthday" field // contains April for the month, 19 for the day, and 1950 for the year. var contacts = ContactsApp.getContactsByDate(ContactsApp.Month.APRIL, 19, 1950, ContactsApp.Field.BIRTHDAY);
Parameters
Name | Type | Description |
---|---|---|
month | Month | the month to match, as one of the values from ContactsApp.Month |
day | Integer | the day to match |
year | Integer | the year to match, can be null |
label |
| the field to search within, from ContactsApp.Field |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByDate(month, day, year, label)
getContactsByDate(month, day, year, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a given month, day, and year for a particular custom field.
// The code below returns an array of contacts where the contact's custom "Start Date" field // contains April for the month, 19 for the day, and 2011 for the year. var contacts = ContactsApp.getContactsByDate(ContactsApp.Month.APRIL, 19, 2011, 'Start Date');
Parameters
Name | Type | Description |
---|---|---|
month | Month | the month to match, as one of the values from ContactsApp.Month |
day | Integer | the day to match |
year | Integer | the year to match, can be null |
label | String | the custom field to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByDate(month, day, label)
getContactsByDate(month, day, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a given month and day for a particular custom field.
// The code below returns an array of contacts where the contact's custom "Start Date" field // contains April for the month and 19 for the day. var contacts = ContactsApp.getContactsByDate(ContactsApp.Month.APRIL, 19, 'Start Date');
Parameters
Name | Type | Description |
---|---|---|
month | Month | the month to match, as one of the values from ContactsApp.Month |
day | Integer | the day to match |
label | String | the custom field to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByEmailAddress(query)
getContactsByEmailAddress(query)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching an email address.
// The code below returns an array of contacts where the contact's email address contains // "[email protected]'. var contacts = ContactsApp.getContactsByEmailAddress('[email protected]');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact email addresses |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByEmailAddress(query, label)
getContactsByEmailAddress(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching an email address, limited to a specific field.
// The code below returns an array of contacts where the contact's email address contains // "[email protected]" in the Home email field. var contacts = ContactsApp.getContactsByEmailAddress('[email protected]', ContactsApp.Field.HOME_EMAIL);
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact email addresses |
label |
| the field to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByEmailAddress(query, label)
getContactsByEmailAddress(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching an email address, limited to the specified custom email address label.
// The code below returns an array of contacts where the contact's email address contains // "[email protected]" in a custom email address label (created by the user) called // "alternate". var contacts = ContactsApp.getContactsByEmailAddress('[email protected]', 'alternate');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact email addresses with the specified custom email address label |
label | String | the custom email address label to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByGroup(group)
getContactsByGroup(group)
Deprecated. This function is deprecated and should not be used in new scripts.
Get the contacts in a given ContactGroup.
// The code below returns an array of contacts in the ContactGroup with the name // "Work Friends". var group = ContactsApp.getContactGroup('Work Friends'); var contacts = ContactsApp.getContactsByGroup(group);
Parameters
Name | Type | Description |
---|---|---|
group |
| the group of contacts |
Return
— an array of of contacts in the given groupContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByIM(query)
getContactsByIM(query)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching an instant messaging address.
// The code below returns an array of contacts where the contact's instant messaging address // contains "ChatWithJohnDoe" in any instant messaging field. var contacts = ContactsApp.getContactsByIM('ChatWithJohnDoe');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's instant messaging addresses |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByIM(query, label)
getContactsByIM(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching an instant messaging address, limited to a specific field.
// The code below returns an array of contacts where the contact's instant messaging address // contains "ChatWithJohnDoe" in the AIM instant messaging field. var contacts = ContactsApp.getContactsByIM('ChatWithJohnDoe', ContactsApp.Field.AIM);
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's instant messaging addresses |
label |
| the field to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByIM(query, label)
getContactsByIM(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching an instant messaging address, limited to the specified custom instant messaging label.
// The code below returns an array of contacts where the contact's instant messaging address // contains "ChatWithJohnDoe" in a custom instant messaging label (created by the user) called // "eBuddy". var contacts = ContactsApp.getContactsByIM('ChatWithJohnDoe', 'eBuddy');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's instant messaging addresses with the specified custom instant messaging label |
label | String | the custom instant messaging label to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByJobTitle(query)
getContactsByJobTitle(query)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching the job title field.
// The code below returns an array of contacts where the contact's job title field // contains "Product Manager". var contacts = ContactsApp.getContactsByJobTitle('Product Manager');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's job title field |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByName(query)
getContactsByName(query)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a name.
// The code below returns an array of contacts where the contact name contains "John" var contacts = ContactsApp.getContactsByName('John');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact names |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByName(query, label)
getContactsByName(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a name, limited to a specific field.
// The code below returns an array of contacts where the contact name contains "John" // in the Given Name field. var contacts = ContactsApp.getContactsByName('John', ContactsApp.Field.GIVEN_NAME);
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact names |
label |
| the field to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByNotes(query)
getContactsByNotes(query)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching the notes field.
// The code below returns an array of contacts where the contact's notes field // contains "sent birthday card". var contacts = ContactsApp.getContactsByNotes('sent birthday card');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's notes field |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByPhone(query)
getContactsByPhone(query)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a phone number.
This method will expand out lettered phone numbers, so if you search for '212-555-CODE' and you have '212-555-2633' in your contacts or vice versa, the method will find the appropriate contact.
// The code below returns an array of contacts where the contact's phone number contains // "212-555-1234' in any phone number field. var contacts = ContactsApp.getContactsByPhone('212-555-1234');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's phone numbers |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByPhone(query, label)
getContactsByPhone(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a phone number, limited to a specific field.
This method will expand out lettered phone numbers, so if you search for '212-555-CODE' and you have '212-555-2633' in your contacts or vice versa, the method will find the appropriate contact.
// The code below returns an array of contacts where the contact's phone number contains // "212-555-1234" in the Home phone number field. var contacts = ContactsApp.getContactsByPhone('212-555-1234', ContactsApp.Field.HOME_PHONE);
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's phone numbers |
label |
| the field to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByPhone(query, label)
getContactsByPhone(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a phone number, limited to the specified custom phone number label.
This method will expand out lettered phone numbers, so if you search for '212-555-CODE' and you have '212-555-2633' in your contacts or vice versa, the method will find the appropriate contact.
// The code below returns an array of contacts where the contact's phone number contains // "212-555-1234" in a custom phone number label (created by the user) called // "alternate". var contacts = ContactsApp.getContactsByPhone('212-555-1234', 'alternate');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's phone numbers with the specified custom phone number label |
label | String | the custom phone number label to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByUrl(query)
getContactsByUrl(query)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a URL.
// The code below returns an array of contacts where the contact's URL contains // "www.example.com' in any URL field. var contacts = ContactsApp.getContactsByUrl('www.example.com');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's URLs |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByUrl(query, label)
getContactsByUrl(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a URL, limited to a specific field.
// The code below returns an array of contacts where the contact's URL contains // "www.example.com" in the Work URL field. var contacts = ContactsApp.getContactsByUrl('www.example.com', ContactsApp.Field.WORK_WEBSITE);
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's URLs |
label |
| the field to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
See also
getContactsByUrl(query, label)
getContactsByUrl(query, label)
Deprecated. This function is deprecated and should not be used in new scripts.
Get contacts matching a URL, limited to the specified custom URL label.
// The code below returns an array of contacts where the contact's URL contains // "www.example.com" in a custom URL label (created by the user) called // "alternate work". var contacts = ContactsApp.getContactsByUrl('www.example.com', 'alternate work');
Parameters
Name | Type | Description |
---|---|---|
query | String | the string to search for in contact's URLs with the specified custom URL label |
label | String | the custom URL label to search within |
Return
— an array of matching contactsContact[]
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds