Class EmailField

Champ d'adresse e-mail

Obsolète. Utilisez plutôt le service avancé de l'API People.

Champ d'adresse e-mail dans un contact.

Méthodes

MéthodeType renvoyéBrève description
getAddress()StringObtenez l'adresse pour ce champ.
getLabel()ObjectRécupère le libellé de ce champ.
isPrimary()BooleanIndique si cette valeur est la valeur du champ principal.
setAddress(address)EmailFieldDéfinit l'adresse de ce champ.
setAsPrimary()EmailFieldDéfinit ce champ sur "principal".
setLabel(field)EmailFieldDéfinit le libellé de ce champ.
setLabel(label)EmailFieldDéfinit le libellé de ce champ.
MéthodeType renvoyéBrève description
deleteEmailField()voidSupprime cette adresse e-mail du contact.
getDisplayName()StringRenvoie le nom à afficher pour cette adresse e-mail.
setDisplayName(name)EmailFieldDéfinit le nom à afficher pour cette adresse e-mail.

Documentation détaillée

getAddress()

Obtenez l'adresse pour ce champ.

// 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());

Renvois

String : adresse sous forme de chaîne

Autorisation

Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:

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

getLabel()

Récupère le libellé de ce champ. Il peut s'agir d'un champ, d'un champ étendu ou d'une chaîne.

// 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());
}

Renvois

Object : libellé de ce champ

Autorisation

Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:

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

isPrimary()

Indique si cette valeur est la valeur du champ principal.

// 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());

Renvois

Boolean : indique si l'élément est principal

Autorisation

Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:

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

setAddress(address)

Définit l'adresse de ce champ.

// 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');

Paramètres

NomTypeDescription
addressStringla nouvelle adresse ;

Renvois

EmailField : champ utile pour le chaînage

Autorisation

Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:

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

setAsPrimary()

Définit ce champ sur "principal".

// 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();

Renvois

EmailField : cette FieldValue pour le chaînage

Autorisation

Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:

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

setLabel(field)

Définit le libellé de ce champ.

// 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);

Paramètres

NomTypeDescription
fieldFieldle nouveau libellé standard

Renvois

EmailField : cette FieldValue pour le chaînage

Autorisation

Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:

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

setLabel(label)

Définit le libellé de ce champ.

// 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');

Paramètres

NomTypeDescription
labelStringle nouveau libellé de ce champ

Renvois

EmailField : champ utile pour le chaînage

Autorisation

Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:

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

Méthodes obsolètes

Obsolète. Cette fonction est obsolète et ne doit pas être utilisée dans les nouveaux scripts.

Supprime cette adresse e-mail du contact.

// 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();

Autorisation

Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:

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

Obsolète. Cette fonction est obsolète et ne doit pas être utilisée dans les nouveaux scripts.

Renvoie le nom à afficher pour cette adresse e-mail.

// 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());

Renvois

String : nom à afficher pour cet e-mail

Autorisation

Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:

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

Obsolète. Cette fonction est obsolète et ne doit pas être utilisée dans les nouveaux scripts.

Définit le nom à afficher pour cette adresse e-mail.

// 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');

Paramètres

NomTypeDescription
nameStringle nouveau nom à afficher pour cette adresse e-mail ;

Renvois

EmailField : champ d'adresse e-mail, utile pour la concaténation

Autorisation

Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:

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