Class Contact

Contact

Deprecated. Instead, use the People API advanced service

A Contact contains the name, address, and various contact details of a contact.

MethodReturn typeBrief description
addAddress(label, address)AddressFieldAdds an address to the contact with either a standard or custom label.
addCompany(company, title)CompanyFieldAdds a company to the contact.
addCustomField(label, content)CustomFieldAdds a custom field to the contact with either an extended or custom label.
addDate(label, month, day, year)DateFieldAdds a date to the contact with either an standard or custom label.
addEmail(label, address)EmailFieldAdd an email address with a standard label (home, work, etc.) or a custom label
{@code
// The code below retrieves a contact named "John Doe" and adds the email
// address "j.doe@example.com" to the ContactsApp.Field.HOME_EMAIL label.
addIM(label, address)IMFieldAdds an IM address to the contact with either a standard or custom label.
addPhone(label, number)PhoneFieldAdds a phone number to the contact with either a standard or custom label.
addToGroup(group)ContactAdds this contact to the given contact group.
addUrl(label, url)UrlFieldAdds a URL to the contact with either a standard or custom label.
deleteContact()voidDeletes this contact.
getAddresses()AddressField[]Gets all the addresses for this contact.
getAddresses(label)AddressField[]Gets all the addresses for this contact matching a particular field.
getCompanies()CompanyField[]Gets all the companies for this contact.
getContactGroups()ContactGroup[]Gets all the contact groups that contain this contact.
getCustomFields()CustomField[]Gets all the custom fields for this contact.
getCustomFields(label)CustomField[]Gets all the custom fields for this contact matching a particular field.
getDates()DateField[]Gets all the dates for this contact.
getDates(label)DateField[]Gets all the dates for this contact matching a particular field.
getEmailAddresses()String[]Gets a list of the email addresses available for this Contact.
getEmails()EmailField[]Gets the email addresses of this contact.
getEmails(label)EmailField[]Gets the email addresses for this contact matching a particular field.
getFamilyName()StringGets the family name (last name) of the contact as a string.
getFullName()StringGets the full name (given name and last name) of the contact as a string.
getGivenName()StringGets the given name (first name) of the contact as a string.
getHomeAddress()StringGets the home address of this Contact, or empty string if none exists.
getHomeFax()StringGets the home fax number of this Contact or empty string if none exists.
getHomePhone()StringGets the home phone number of this Contact or empty string if none exists.
getIMs()IMField[]Gets all the IM addresses for this contact.
getIMs(label)IMField[]Gets all the IM addresses for this contact matching a particular field.
getId()StringReturns the unique id of this contact.
getInitials()StringGets the contact's initials.
getLastUpdated()DateGets the date this contact was last updated.
getMaidenName()StringGets the maiden name of the contact as a string.
getMiddleName()StringGets the middle name of the contact as a string.
getMobilePhone()StringGets the mobile phone number of this Contact or empty string if none exists.
getNickname()StringGets the nickname of the contact as a string.
getNotes()StringGets the notes associated with this contact, or an empty string if there are no notes.
getPager()StringGets the pager phone number of this Contact or empty string if none exists.
getPhones()PhoneField[]Gets all the phone numbers for this contact.
getPhones(label)PhoneField[]Gets all the phone numbers for this contact matching a particular field.
getPrefix()StringGets the prefix to the contact's name.
getPrimaryEmail()StringGets the primary email address of the contact as a string.
getShortName()StringGets the short name of the contact as a string.
getSuffix()StringGets the suffix to the contact's name.
getUrls()UrlField[]Gets all the URLs for this contact.
getUrls(label)UrlField[]Gets all the URLs for this contact matching a particular field.
getUserDefinedField(key)StringGets the user defined value associated with the given key.
getUserDefinedFields()ObjectGets all the user defined fields for this Contact and returns them as the properties of a JavaScript Object.
getWorkAddress()StringGets the work address of this Contact, or empty string if none exists.
getWorkFax()StringGets the work fax number of this Contact or empty string if none exists.
getWorkPhone()StringGets the work phone number of this Contact or empty string if none exists.
removeFromGroup(group)ContactRemoves this contact from the given contact group.
setFamilyName(familyName)ContactSets the family name (last name) of the contact.
setFullName(fullName)ContactSets the full name (given name and last name) of the contact.
setGivenName(givenName)ContactSets the given name (first name) of the contact.
setHomeAddress(addr)voidSets the home address of this Contact.
setHomeFax(phone)voidSets the home fax number of this Contact.
setHomePhone(phone)voidSets the home phone number of this Contact.
setInitials(initials)ContactSets the contact's initials.
setMaidenName(maidenName)ContactSets the maiden name of the contact.
setMiddleName(middleName)ContactSets the middle name of the contact.
setMobilePhone(phone)voidSets the mobile phone number of this Contact.
setNickname(nickname)ContactSets the nickname of the contact.
setNotes(notes)ContactSets the notes associated with this contact.
setPager(phone)voidSets the pager number of this Contact.
setPrefix(prefix)ContactSets the prefix to the contact's name.
setPrimaryEmail(primaryEmail)voidSets the primary email address of this Contact.
setShortName(shortName)ContactSets the short name of the contact.
setSuffix(suffix)ContactSets the suffix to the contact's name.
setUserDefinedField(key, value)voidSets a single user defined field for this Contact, to be stored with a given key.
setUserDefinedFields(o)voidSets the user defined fields for this Contact with the properties of the given Object.
setWorkAddress(addr)voidSets the work address of this Contact.
setWorkFax(phone)voidSets the work fax number of this Contact.
setWorkPhone(phone)voidSets the work phone number of this Contact.

Deprecated methods

Deprecated. This function is deprecated and should not be used in new scripts.

Adds an address to the contact with either a standard or custom label.

The label can be either from ContactsApp.Field or a custom label string.

// The code below retrieves a contact named "John Doe" and adds the address
// "123 Main St, Some City, NY 10011" with the ContactsApp.Field.WORK_ADDRESS
// label.
const contacts = ContactsApp.getContactsByName('John Doe');
const address = contacts[0].addAddress(
    ContactsApp.Field.WORK_ADDRESS,
    '123 Main St, Some City, NY 10011',
);

Parameters

NameTypeDescription
labelObjectthe label of the new address, either from ContactsApp.Field or a custom string
addressStringthe new address

Return

AddressField — the newly created field

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Adds a company to the contact.

// The code below retrieves a contact named "John Doe" and adds the company
// "Google" and the job title "Product Manager".
const contacts = ContactsApp.getContactsByName('John Doe');
const url = contacts[0].addCompany('Google', 'Product Manager');

Parameters

NameTypeDescription
companyStringthe name of the company to add to this contact
titleStringthe job title associated with this contact for this company

Return

CompanyField — the newly created field

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Adds a custom field to the contact with either an extended or custom label.

The label can be either from ContactsApp.ExtendedField or a custom label string.

// The code below retrieves a contact named "John Doe" and adds the custom field
// ContactsApp.ExtendedField.HOBBY with the value "hiking".
// Note that ContactsApp.ExtendedField.HOBBY is not the same as a custom field
// named 'HOBBY'.
const contacts = ContactsApp.getContactsByName('John Doe');
contacts[0].addCustomField(ContactsApp.ExtendedField.HOBBY, 'hiking');

Parameters

NameTypeDescription
labelObjectthe label of the new address, either from ContactsApp.ExtendedField or a custom string
contentObjectthe value to store in the custom field

Return

CustomField — the newly created field

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Adds a date to the contact with either an standard or custom label.

The label can be either from ContactsApp.Field or a custom label string.

// The code below retrieves a contact named "John Doe" and adds a
// ContactsApp.ExtendedField.BIRTHDAY with the value "April 19, 1950".
const contacts = ContactsApp.getContactsByName('John Doe');
const birthday = contacts[0].addDate(
    ContactsApp.Field.BIRTHDAY,
    ContactsApp.Month.APRIL,
    19,
    1950,
);

Parameters

NameTypeDescription
labelObjectthe label of the new date, either from ContactsApp.Field or a custom string
monthMonththe month, from ContactApps.Month
dayIntegerthe day
yearIntegerthe year

Return

DateField — the newly created date

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Add an email address with a standard label (home, work, etc.) or a custom label

// The code below retrieves a contact named "John Doe" and adds the email
// address "j.doe@example.com" to the ContactsApp.Field.HOME_EMAIL label.
const contacts = ContactsApp.getContactsByName('John Doe');
const emailField = contacts[0].addEmail(
    ContactsApp.Field.HOME_EMAIL,
    'j.doe@example.com',
);

Parameters

NameTypeDescription
labelObjectthe label of the new email, either from ContactsApp.Field or a custom string
addressStringthe new email address

Return

EmailField — the newly added field

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Adds an IM address to the contact with either a standard or custom label.

The label can be either from ContactsApp.Field or a custom label string.

// The code below retrieves a contact named "John Doe" and adds the IM address
// "ChatWithJohn" with the ContactsApp.Field.AIM label.
const contacts = ContactsApp.getContactsByName('John Doe');
const email = contacts[0].addIM(ContactsApp.Field.AIM, 'ChatWithJohn');

Parameters

NameTypeDescription
labelObjectthe label of the new IM address, either from ContactsApp.Field or a custom string
addressStringthe new IM address

Return

IMField — the newly created field

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Adds a phone number to the contact with either a standard or custom label.

The label can be either from ContactsApp.Field or a custom label string.

// The code below retrieves a contact named "John Doe" and adds the phone number
// "212-555-1234" with the ContactsApp.Field.WORK_PHONE label.
const contacts = ContactsApp.getContactsByName('John Doe');
const phone = contacts[0].addPhone(
    ContactsApp.Field.WORK_PHONE,
    '212-555-1234',
);

Parameters

NameTypeDescription
labelObjectthe label of the new phone number, either from ContactsApp.Field or a custom string
numberStringthe new phone number

Return

PhoneField — the newly created field

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Adds this contact to the given contact group.

// The code below creates a new contact and then adds it to the contact group
// named "Work Friends"
let contact = ContactsApp.createContact('John', 'Doe', 'john.doe@example.com');
const group = ContactsApp.getContactGroup('Work Friends');
contact = contact.addToGroup(group);

Parameters

NameTypeDescription
groupContactGroupthe contact group to add this contact to

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Adds a URL to the contact with either a standard or custom label.

The label can be either from ContactsApp.Field or a custom label string.

// The code below retrieves a contact named "John Doe" and adds the URL
// "http://www.example.com" with the ContactsApp.Field.WORK_WEBSITE label.
const contacts = ContactsApp.getContactsByName('John Doe');
const url = contacts[0].addUrl(
    ContactsApp.Field.WORK_WEBSITE,
    'http://www.example.com',
);

Parameters

NameTypeDescription
labelObjectthe label of the new address, either from ContactsApp.Field or a custom string
urlStringthe new URL

Return

UrlField — the newly created field

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Deletes this contact.

const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  contacts[i].deleteContact();
}

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the addresses for this contact.

// The code below logs the addresses of all the contacts whose names contain
// "John Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  Logger.log(contacts[i].getAddresses());
}

Return

AddressField[] — a list of addresses

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the addresses for this contact matching a particular field.

The label can be either from ContactsApp.Field or a custom label string.

// The code below retrieves a contact named "John Doe" and logs the addresses
// associated with that contact that are in the ContactsApp.Field.WORK_ADDRESS
// label.
const contacts = ContactsApp.getContactsByName('John Doe');
const addresses = contacts[0].getAddresses(ContactsApp.Field.WORK_ADDRESS);
for (const i in addresses) {
  Logger.log(addresses[i].getAddress());
}

Parameters

NameTypeDescription
labelObjectthe label to match, either from ContactsApp.Field or a custom string

Return

AddressField[] — a list of addresses

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the companies for this contact.

// The code below logs the company names of all the contacts whose names contain
// "John Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  const companies = contacts[i].getCompanies();
  for (const j in companies) {
    Logger.log(companies[j].getCompanyName());
  }
}

Return

CompanyField[] — a list of companies

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the contact groups that contain this contact.

// The code below gets a contact named "John Doe" and retrieves all the contact
// groups that the contact belongs to
const contacts = ContactsApp.getContactsByName('John Doe');
const groups = contacts[0].getContactGroups();

Return

ContactGroup[] — the groups containing this contact

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the custom fields for this contact.

// The code below retrieves a contact named "John Doe" and logs the custom
// fields associated with that contact
const contacts = ContactsApp.getContactsByName('John Doe');
const fields = contacts[0].getCustomFields();
for (const i in fields) {
  Logger.log(fields[i].getValue());
}

Return

CustomField[] — a list of custom fields

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the custom fields for this contact matching a particular field.

The label can be either a standard label from ContactsApp.ExtendedField or a custom label string.

// The code below retrieves a contact named "John Doe" and logs the custom
// fields associated with that contact that are in the
// ContactsApp.ExtendedField.HOBBY label.
const contacts = ContactsApp.getContactsByName('John Doe');
const hobbies = contacts[0].getCustomFields(ContactsApp.ExtendedField.HOBBY);
for (const i in hobbies) {
  Logger.log(hobbies[i].getValue());
}

Parameters

NameTypeDescription
labelObjectthe label to match, either from ContactsApp.ExtendedField or a custom string

Return

CustomField[] — a list of custom fields

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the dates for this contact.

// The code below retrieves a contact named "John Doe" and logs the label of the
// date associated with that contact
const contacts = ContactsApp.getContactsByName('John Doe');
const dates = contacts[0].getDates();
for (const i in dates) {
  Logger.log(dates[i].getLabel());
}

Return

DateField[] — a list of dates

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the dates for this contact matching a particular field.

The label can be either a standard label from ContactsApp.Field or a custom label string.

// The code below retrieves a contact named "John Doe" and logs the day of the
// month associated with that contact that are in the ContactsApp.Field.BIRTHDAY
// label.
const contacts = ContactsApp.getContactsByName('John Doe');
const birthdays = contacts[0].getDates(ContactsApp.Field.BIRTHDAY);
for (const i in birthdays) {
  Logger.log(birthdays[i].getDay());
}

Parameters

NameTypeDescription
labelObjectthe label to match, either from ContactsApp.Field or a custom string

Return

DateField[] — a list of dates

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets a list of the email addresses available for this Contact.

Return

String[] — a list of email addresses available for this Contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets the email addresses of this contact.

// The code below retrieves a contact named "John Doe" and logs the email
// addresses associated with that contact
const contacts = ContactsApp.getContactsByName('John Doe');
const emails = contacts[0].getEmails();
for (const i in emails) {
  Logger.log(emails[i].getAddress());
}

Return

EmailField[] — the list of email addresses for the contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the email addresses for this contact matching a particular field.

The label can be either a standard label from ContactsApp.Field or a custom label string.

// The code below retrieves a contact named "John Doe" and logs the email
// addresses associated with that contact that are in the
// ContactsApp.Field.HOME_EMAIL label.
const contacts = ContactsApp.getContactsByName('John Doe');
const emails = contacts[0].getEmails(ContactsApp.Field.HOME_EMAIL);
for (const i in emails) {
  Logger.log(emails[i].getAddress());
}

Parameters

NameTypeDescription
labelObjectthe label to match, either from ContactsApp.Field or a custom string

Return

EmailField[] — the list of email addresses for the contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the family name (last name) of the contact as a string.

// The code below logs the family name of all the contacts whose names contain
// "John"
const contacts = ContactsApp.getContactsByName('John');
for (const i in contacts) {
  Logger.log(contacts[i].getFamilyName());
}

Return

String — the family name of the contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the full name (given name and last name) of the contact as a string.

// The code below logs the full name of all the contacts whose names contain
// "John"
const contacts = ContactsApp.getContactsByName('John');
for (const i in contacts) {
  Logger.log(contacts[i].getFullName());
}

Return

String — the full name of the contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the given name (first name) of the contact as a string.

// The code below logs the given name of all the contacts whose names contain
// "Smith"
const contacts = ContactsApp.getContactsByName('Smith');
for (const i in contacts) {
  Logger.log(contacts[i].getGivenName());
}

Return

String — the given name of the contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the home address of this Contact, or empty string if none exists.

Return

String — the home address of this Contact, or empty string if none exists

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets the home fax number of this Contact or empty string if none exists.

Return

String — the home fax number of this Contact or empty string if none exists

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets the home phone number of this Contact or empty string if none exists.

Return

String — the home phone number of this Contact or empty string if none exists

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the IM addresses for this contact.

// The code below logs the IM addresses of all the contacts whose names contain
// "John Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  Logger.log(contacts[i].getIMs());
}

Return

IMField[] — a list of IM addresses

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the IM addresses for this contact matching a particular field.

The label can be either from ContactsApp.Field or a custom label string.

// The code below retrieves a contact named "John Doe" and logs the IM addresses
// associated with that contact that are in the ContactsApp.Field.GOOGLE_TALK
// label.
const contacts = ContactsApp.getContactsByName('John Doe');
const imAddresses = contacts[0].getIMs(ContactsApp.Field.GOOGLE_TALK);
for (const i in imAddresses) {
  Logger.log(imAddresses[i].getAddress());
}

Parameters

NameTypeDescription
labelObjectthe label to match, either from ContactsApp.Field or a custom string

Return

IMField[] — a list of IM addresses

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Returns the unique id of this contact.

const contact = ContactsApp.createContact(
    'John',
    'Doe',
    'john.doe@example.com',
);
const id = contact.getId();

Return

String — the id of this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets the contact's initials.

// The code below logs the initials of all the contacts whose names contain
// "John Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  Logger.log(contacts[i].getInitials());
}

Return

String — the initials of the contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the date this contact was last updated.

// The code below logs the last updated date of all the contacts whose names
// contain "John Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  Logger.log(contacts[i].getLastUpdated());
}

Return

Date — the date this contact was last updated

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets the maiden name of the contact as a string.

// The code below logs the maiden name of all the contacts whose names contain
// "Jane"
const contacts = ContactsApp.getContactsByName('Jane');
for (const i in contacts) {
  Logger.log(contacts[i].getMaidenName());
}

Return

String — the maiden name of the contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the middle name of the contact as a string.

// The code below logs the middle name of all the contacts whose names contain
// "Smith"
const contacts = ContactsApp.getContactsByName('Smith');
for (const i in contacts) {
  Logger.log(contacts[i].getMiddleName());
}

Return

String — the middle name of the contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the mobile phone number of this Contact or empty string if none exists.

Return

String — the mobile phone number of this Contact or empty string if none exists

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets the nickname of the contact as a string.

// The code below logs the nickname of all the contacts whose names contain
// "John Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  Logger.log(contacts[i].getNickname());
}

Return

String — the nickname of the contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the notes associated with this contact, or an empty string if there are no notes.

// The code below logs the notes of all the contacts whose names contain "John
// Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  Logger.log(contacts[i].getNotes());
}

Return

String — the notes associated with this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the pager phone number of this Contact or empty string if none exists.

Return

String — the pager phone number of this Contact or empty string if none exists

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the phone numbers for this contact.

// The code below logs the phone numbers of all the contacts whose names contain
// "John Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  Logger.log(contacts[i].getPhones());
}

Return

PhoneField[] — a list of phone numbers

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the phone numbers for this contact matching a particular field.

The label can be either from ContactsApp.Field or a custom label string.

// The code below retrieves a contact named "John Doe" and logs the phone
// numbers associated with that contact that are in the
// ContactsApp.Field.WORK_PHONE label.
const contacts = ContactsApp.getContactsByName('John Doe');
const phones = contacts[0].getPhones(ContactsApp.Field.WORK_PHONE);
for (const i in phones) {
  Logger.log(phones[i].getPhoneNumber());
}

Parameters

NameTypeDescription
labelObjectthe label to match, either from ContactsApp.Field or a custom string

Return

PhoneField[] — a list of phone numbers

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the prefix to the contact's name.

// The code below logs the prefix of all the contacts whose names contain "John
// Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  Logger.log(contacts[i].getPrefix());
}

Return

String — the prefix of the contact's name

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the primary email address of the contact as a string.

// The code below logs the primary email address of all the contacts whose names
// contain "John Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  Logger.log(contacts[i].getPrimaryEmail());
}

Return

String — the primary email address of the contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets the short name of the contact as a string.

// The code below logs the short name of all the contacts whose names contain
// "Johnathan"
const contacts = ContactsApp.getContactsByName('Johnathan');
for (const i in contacts) {
  Logger.log(contacts[i].getShortName());
}

Return

String — the short name of the contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the suffix to the contact's name.

// The code below logs the suffix of all the contacts whose names contain "John
// Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  Logger.log(contacts[i].getSuffix());
}

Return

String — the suffix of the contact's name

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the URLs for this contact.

// The code below logs the URLs of all the contacts whose names contain "John
// Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  Logger.log(contacts[i].getUrls());
}

Return

UrlField[] — a list of URLs

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the URLs for this contact matching a particular field.

The label can be either from ContactsApp.Field or a custom label string.

// The code below retrieves a contact named "John Doe" and logs the URLs
// associated with that contact that are in the ContactsApp.Field.WORK_WEBSITE
// label.
const contacts = ContactsApp.getContactsByName('John Doe');
const urls = contacts[0].getUrls(ContactsApp.Field.WORK_WEBSITE);
for (const i in urls) {
  Logger.log(urls[i].getAddress());
}

Parameters

NameTypeDescription
labelObjectthe label to match, either from ContactsApp.Field or a custom string

Return

UrlField[] — a list of URLs

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Gets the user defined value associated with the given key.

Parameters

NameTypeDescription
keyStringthe key can be any basic type (String, int, etc.)

Return

String — the user defined content that has been stored with this key

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets all the user defined fields for this Contact and returns them as the properties of a JavaScript Object.

Return

Object — the user defined fields for this Contact, as properties of a JavaScript Object

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets the work address of this Contact, or empty string if none exists.

Return

String — the work address of this Contact, or empty string if none exists

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets the work fax number of this Contact or empty string if none exists.

Return

String — the work fax number of this Contact or empty string if none exists

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Gets the work phone number of this Contact or empty string if none exists.

Return

String — the work phone number of this Contact or empty string if none exists

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Removes this contact from the given contact group.

// The code below gets all the contacts named "John Doe" and then removes each
// of them from the "Work Friends" contact group
const contacts = ContactsApp.getContactsByName('John Doe');
const group = ContactsApp.getContactGroup('Work Friends');
for (const i in contacts) {
  contacts[i] = contacts[i].removeFromGroup(group);
}

Parameters

NameTypeDescription
groupContactGroupthe contact group to remove this contact from

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets the family name (last name) of the contact.

// The code below changes the family name of all the contacts whose names are
// "John Doe" to "Doe-Smith"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  contacts[i].setFamilyName('Doe-Smith');
}

Parameters

NameTypeDescription
familyNameStringthe new family name of the contact

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets the full name (given name and last name) of the contact.

// The code below changes the full name of all the contacts whose names are
// "John Doe" to "Johnny Doe"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  contacts[i].setFullName('Johnny Doe');
}

Parameters

NameTypeDescription
fullNameStringthe new full name of the contact

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets the given name (first name) of the contact.

// The code below changes the given name of all the contacts whose names are
// "John Doe" to "Johnny"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  contacts[i].setGivenName('Johnny');
}

Parameters

NameTypeDescription
givenNameStringthe new given name of the contact

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets the home address of this Contact.

Parameters

NameTypeDescription
addrStringthe home address to set

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the home fax number of this Contact.

Parameters

NameTypeDescription
phoneStringthe home fax number to set

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the home phone number of this Contact.

Parameters

NameTypeDescription
phoneStringthe home phone number to set

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the contact's initials.

// The code below sets the initials of all the contacts whose names are
// "Johnathan Doe" to "JD"
const contacts = ContactsApp.getContactsByName('Johnathan Doe');
for (const i in contacts) {
  contacts[i].setInitials('JD');
}

Parameters

NameTypeDescription
initialsStringthe new initials of the contact

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets the maiden name of the contact.

// The code below changes the maiden name of all the contacts whose names are
// "Jane Doe" to "Smith"
const contacts = ContactsApp.getContactsByName('Jane Doe');
for (const i in contacts) {
  contacts[i].setMaidenName('Smith');
}

Parameters

NameTypeDescription
maidenNameStringthe new maiden name of the contact

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets the middle name of the contact.

// The code below changes the middle name of all the contacts whose names are
// "John Doe" to "Danger"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  contacts[i].setMiddleName('Danger');
}

Parameters

NameTypeDescription
middleNameStringthe new middle name of the contact

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets the mobile phone number of this Contact.

Parameters

NameTypeDescription
phoneStringthe mobile phone number to set

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the nickname of the contact.

// The code below changes the nickname of all the contacts whose names are "John
// Doe" to "JohnnyD"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  contacts[i].setNickname('JohnnyD');
}

Parameters

NameTypeDescription
nicknameStringthe new nickname of the contact

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets the notes associated with this contact.

// The code below sets the notes of all the contacts whose names are "John Doe"
// to "Met him at the hackathon"
const contacts = ContactsApp.getContactsByName('John Doe');
for (const i in contacts) {
  contacts[i].setNotes('Met him at the hackathon');
}

Parameters

NameTypeDescription
notesStringthe notes to be stored for this contact

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets the pager number of this Contact.

Parameters

NameTypeDescription
phoneStringthe pager number to set

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the prefix to the contact's name.

// The code below sets the prefix of all the contacts whose names are "Johnathan
// Doe" to "Mr"
const contacts = ContactsApp.getContactsByName('Johnathan Doe');
for (const i in contacts) {
  contacts[i].setPrefix('Mr');
}

Parameters

NameTypeDescription
prefixStringthe new prefix of the contact's name

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets the primary email address of this Contact.

Parameters

NameTypeDescription
primaryEmailStringthe primary email address to set

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the short name of the contact.

// The code below changes the short name of all the contacts whose names are
// "Johnathan Doe" to "John"
const contacts = ContactsApp.getContactsByName('Johnathan Doe');
for (const i in contacts) {
  contacts[i].setShortName('John');
}

Parameters

NameTypeDescription
shortNameStringthe new short name of the contact

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets the suffix to the contact's name.

// The code below sets the suffix of all the contacts whose names are "Johnathan
// Doe" to "Jr"
const contacts = ContactsApp.getContactsByName('Johnathan Doe');
for (const i in contacts) {
  contacts[i].setSuffix('Jr');
}

Parameters

NameTypeDescription
suffixStringthe new suffix of the contact's name

Return

Contact — this contact

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

See also


Deprecated. This function is deprecated and should not be used in new scripts.

Sets a single user defined field for this Contact, to be stored with a given key.

Parameters

NameTypeDescription
keyStringthe key can be any basic type (String, int, etc.)
valueStringthe value can be any basic type (String, int, etc.)

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the user defined fields for this Contact with the properties of the given Object.

Parameters

NameTypeDescription
oObjectan Object with one or more properties in the form {key: value}

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the work address of this Contact.

Parameters

NameTypeDescription
addrStringthe work address to set

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the work fax number of this Contact.

Parameters

NameTypeDescription
phoneStringthe work fax number to set

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds

Deprecated. This function is deprecated and should not be used in new scripts.

Sets the work phone number of this Contact.

Parameters

NameTypeDescription
phoneStringthe work phone number to set

Authorization

Scripts that use this method require authorization with one or more of the following scopes:

  • https://www.google.com/m8/feeds