---
title: Email
slug: oip-next/u-nuywfcu1x8y9mcsqws
icon: {"lucideIcon":"📘"}
createdAt: 2024-04-08T10:17:29.000Z
---

# Email

## Description

L'entité Email contient la valeur de l'email ainsi que son type.

## Relations

### Ascendantes

| Entité       | Propriété |
| ------------ | --------- |
| ActivePolicy | emails    |
| Company      | emails    |
| Contact      | emails    |
| Customer     | emails    |
| Employee     | emails    |
| Grantee      | emails    |
| Tns          | emails    |
| User         | emails    |

### Descendantes

| Entité  | Propriété |
| ------- | --------- |
| History | history   |

## Propriétés

| Nom          | Type            | Description                                                                     | Validateur | Lecture seule ? | Dépréciée ? | Dernière version modifiée |
| ------------ | --------------- | ------------------------------------------------------------------------------- | ---------- | --------------- | ----------- | ------------------------- |
| type         | `EmailTypeEnum` | Type de l'email                                                                 |            |                 |             | 2.4.0                     |
| value        | `String`        | Email, ex:                                                                      | /^0$/      |                 |             | 2.4.0                     |
| id           | `String`        | Identifiant de l'entité `Email`                                                 |            | X               |             |                           |
| code         | `String`        | Codification fonctionnelle de l'entité `Email`                                  |            |                 |             |                           |
| externalId   | `String`        | Identifiant de l'entité `Email` dans le système client                          |            |                 |             |                           |
| externalCode | `String`        | Codification fonctionnelle de l'entité `Email` dans le système client           |            |                 |             |                           |
| emailId      | `String`        | Identifiant public de l'entité `Email` dans l'OIP                               |            |                 |             |                           |
| label        | `String`        | Information relative au nom de l'entité `Email` dans son contexte d'utilisation |            |                 |             |                           |
| createdAt    | `Date`          | Date de création de l'entité `Email`                                            |            | X               |             |                           |
| updatedAt    | `Date`          | Date de modification de l'entité `Email`                                        |            | X               |             |                           |

## Enumérations

### EmailTypeEnum

- `PERSONAL`
- `PROFESSIONAL`

## Enumérations génériques

Aucune enumération générique.

## Exemple

```javascript
import { Entities } from '@fasstech/oip-core';
import { getActivePolicyId } from '@fasstech/oip-core/entities/ActivePolicy';
import { getCompanyId } from '@fasstech/oip-core/entities/Company';
import { getEmailCode, getEmailEmailId, getEmailExternalCode, getEmailExternalId, getEmailId, getEmailLabel, getEmailType, getEmailValue, setEmailCode, setEmailEmailId, setEmailExternalCode, setEmailExternalId, setEmailLabel, setEmailType, setEmailValue } from '@fasstech/oip-core/entities/Email';
import { EmailTypeEnum } from '@fasstech/oip-core/entities/Email/enums';
import { getProjectId } from '@fasstech/oip-core/entities/Project';

(async () => {
  let project = await Entities('Project').create();
  let company = await Entities('Company').create();
  let activePolicy = await Entities('ActivePolicy').create();
  const email = await Entities('Email').create();
  
  setEmailType(EmailTypeEnum.PERSONAL, email);
  setEmailValue('value@fasst.io', email);
  setEmailCode('code', email);
  setEmailExternalId('externalId', email);
  setEmailExternalCode('externalCode', email);
  setEmailEmailId('emailId', email);
  setEmailLabel('label', email);
  
  activePolicy = await Entities('Email').save(activePolicy, email);
  company = await Entities('ActivePolicy').save(company, activePolicy);
  project = await Entities('Company').save(project, company);
  await Entities('Project').save(project);
  
  const projectToTest = await Entities('Project').get({ id: getProjectId(project) });
  const companyToTest = await Entities('Company').get(projectToTest, { filter: ({ id }) => id === getCompanyId(company) });
  const activePolicyToTest = await Entities('ActivePolicy').get(companyToTest, { filter: ({ id }) => id === getActivePolicyId(activePolicy) });
  const emailToTest = await Entities('Email').get(activePolicyToTest, { filter: ({ id }) => id === getEmailId(email) });
  
  getEmailType(emailToTest); // EmailTypeEnum.PERSONAL
  getEmailValue(emailToTest); // 'value@fasst.io'
  getEmailCode(emailToTest); // 'code'
  getEmailExternalId(emailToTest); // 'externalId'
  getEmailExternalCode(emailToTest); // 'externalCode'
  getEmailEmailId(emailToTest); // 'emailId'
  getEmailLabel(emailToTest); // 'label'
})();
```
