# Using the CRM Email Builder

Using the _CRM Email_ object type of the _Content Module_ object and the <a class="external-link " href="https://crmhelp.veeva.com/doc/Content/CRM_topics/Multichannel/ApprovedEmail/ManageCreateContent/CreatingContent/EmailBuilder.htm" target="_blank" rel="noopener">CRM Email Builder<i class="fa fa-external-link" aria-hidden="true"></i></a>, users can construct personalized emails with content and rules controlled by your organization. Content owners can deconstruct legacy <a href="/en/gr/12080/">Approved Email</a>
 templates into email _Assets_, reducing the required review time and simplifying the authoring process for Approved Emails.

<a href="https://platform.veevavault.help/assets/images/CRM_Email_Module_23r35.png" data-lightbox="CRM_Email_Module_23r35.png" data-title="" data-alt="CRM Email Module">
  <img class="docimage" src="https://platform.veevavault.help/assets/images/CRM_Email_Module_23r35.png" alt="CRM Email Module" style="max-width: 40%;"  />
</a> 

To compose and send an email using the Email Builder, the documents, fragments, and cells must be in their steady state.

## Configuring the Content Module Lifecycle

Before configuring _CRM Emails_, you must configure the <a href="/en/gr/30683/#state-type">_Complete State_ type</a>
 for the _Content Module Lifecycle_:

  1. Navigate to **Admin > Configuration > Object Lifecycles**.
  2. Click **Content Module Lifecycle**.
  3. Under _State Types_, click **Complete State**.
  4. Click **Edit**.
  5. Select a **State** to associate with the _Complete State_.
  6. Click **Save**. 

## Defining Content Cells

The Email Builder includes the following columns:

  * **Subject**: The email _Subject_
  * **Greeting**: The email _Greeting_
  * **Paragraph 1**: The first paragraph of the email
  * **Paragraph 2**: The second paragraph of the email
  * **Documents**: _Email Fragments_ included in the email
  * **Paragraph 3**: The third paragraph of the email
  * **Closing**: The closing remarks

<div class="note-border alert-info">
  <div class="alert alert-info" role="alert">
    <div><i class="far fa-info-circle"></i></div>
    <div class="alert-text">
      <p><strong>Note</strong>: While you can choose to remove columns, you cannot change the column order.</p>
    </div>
  </div>
</div>



A column can have any number of content cells or no cells at all, and the number of cells in each column may be different.

Each content cell should contain the following information:

  * **Type**: Defines the column the cell belongs to, based on the column types in the list above
  * **Text**: The text in the Email Builder cell. The Email Builder supports the following HTML formats:
      * Bold
      * Italics
      * Underline
      * Hyperlinks
      * Color
      * Approved Email <a class="external-link " href="https://crmhelp.veeva.com/doc/Content/CRM_topics/Multichannel/ApprovedEmail/ManageCreateContent/CreatingContent/ConfigTokens.htm" target="_blank" rel="noopener">merge tokens and standard tokens<i class="fa fa-external-link" aria-hidden="true"></i></a> such as `{{accFname}}`, `{{userName}}`, and `{{userPhoto}}`
  * **Document**: You can associate _Document_ content type cells with an _Email Fragment_, which is inserted when a user selects the cell
  * **Key**: A unique numeric field that can be used to migrate content cells in PromoMats. This only applies if you are using Vault Loader.
  * **Display order**: The text field used to determine the order in which the content cells display in the column. This only applies if you are using Vault Loader.

To enable users to skip a column, leave the cell empty.

Free text, picklist, or other tokens requiring user input are not supported.

The existing Approved Email sync process fetches the Email Builder data from Vault to Veeva CRM.

<a href="https://platform.veevavault.help/assets/images/CRM_Email_Builder_Example_24R1.png" data-lightbox="CRM_Email_Builder_Example_24R1.png" data-title="" data-alt="Email Builder in Veeva CRM">
  <img class="docimage" src="https://platform.veevavault.help/assets/images/CRM_Email_Builder_Example_24R1.png" alt="Email Builder in Veeva CRM" style="max-width: 40%;"  />
</a>

## Updating Email Templates

You must associate the Email Builder with an email template. You can use one Email Builder with multiple email templates; however, each email template can only be associated with one Email Builder. Email templates with an Email Builder are not supported in Recommended Emails, Suggestions, and Events Management.

To associate the Email Builder with an email template, you must <a href="/en/gr/4884/#use-shared-field">add the _Content Module_ field to the _Email Template_ document type</a>
, and inside the _Email Template_, you must assign the associated _CRM Email_ module with the field.

You can define where Email Builder content displays in an email template by inserting the `{{insertEmailBuilder}}` token into an empty `Table` tag. To insert the tag in BEE Editor, select **Merge Tags** and then select **Insert Email Builder**.

You can also define the Email Builder styling by modifying the `Table` tag styles. The defined styles are inherited by the content cells inserted in the table tag. Each inserted row is assigned an _ID_ attribute, so you can optionally customize them by adding CSS in the _Email Template_ and applying the styling via the _ID_ attribute. 

The _IDs_ for each row are defined in the table below. The CSS Example column contains examples of how each row can be styled.

<table>
    <thead>
        <tr>
            <th>Row</th>
            <th>ID</th>
            <th>CSS Example</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Greeting</td>
            <td markdown="span">`ae-greeting`</td>
            <td><pre class="highlight --copy">
            <code>/* Styling for the Greeting row */
.ae-greeting {
    background-color: lightblue;
    font-weight: bold;
}</code></pre></td>
        </tr>
        <tr>
            <td>Paragraph 1</td>
            <td markdown="span">`ae-paragraph1`</td>
            <td><pre class="highlight --copy">
            <code>/* Styling for the Paragraph 1 row */
.ae-paragraph1 {
    color: green;
    font-size: 14px;
}</code></pre></td>
        </tr>
        <tr>
            <td>Paragraph 2</td>
            <td markdown="span">`ae-paragraph2`</td>
            <td><pre class="highlight --copy">
            <code>/* Styling for the Paragraph 2 row */
.ae-paragraph2 {
    border-bottom: 2px solid orange;
}</code></pre></td>
        </tr>
        <tr>
            <td>Document</td>
            <td markdown="span">`ae-document`</td>
            <td><pre class="highlight --copy">
            <code>/* Styling for the Document row */
.ae-document {
    text-align: center;
    background-color: #f0f0f0;
}</code></pre></td>
        </tr>
        <tr>
            <td>Paragraph 3</td>
            <td markdown="span">`ae-paragraph3`</td>
            <td><pre class="highlight --copy">
            <code>/* Styling for the Paragraph 3 row */
.ae-paragraph3 {
    font-style: italic;
}</code></pre></td>
        </tr>
        <tr>
            <td>Closing</td>
            <td markdown="span">`ae-closing`</td>
            <td><pre class="highlight --copy">
            <code>/* Styling for the Closing row */
.ae-closing {
    background-color: darkgray;
    olor: white;
}</code></pre></td>
        </tr>
    </tbody>
</table>

The `{{insertEmailBuilder}}` token is not supported in _Template Fragments_ or _Email Fragments_.

Additionally, _Email Fragments_ should be added from the Email Builder. Do not include the `{{insertEmailFragment}}` token in your _Email Template_.

## Configuring the CRM Email & Email Asset Layouts

If you created _Content Module_ records prior to the 24R1 release, you must enable the _CRM Email_ (`crm_email__v`) object type on the _Content Module_ object before you can use the Email Builder.

Once the object type is enabled, you can configure object type layouts:

  1. Navigate to **Admin > Configuration > Objects > Content Module**.
  2. Click the **Layouts** tab.
  3. Under _Layout Label_, click the **Actions** menu next to _CRM Email Action Layout_ and select **Save As**.
  4. Enter a new **Layout Label**.
  5. Select **Active** in the _Status_ drop-down.
  6. Click **Done**.
  7. Navigate to **Objects > Content Module Asset**.
  8. Repeat steps 2 through 6 for the _Email Asset Action Layout_.

<a href="https://platform.veevavault.help/assets/images/CRM_Email_Action_Layout_23r35.png" data-lightbox="CRM_Email_Action_Layout_23r35.png" data-title="" data-alt="CRM Email Action Layout">
  <img class="docimage" src="https://platform.veevavault.help/assets/images/CRM_Email_Action_Layout_23r35.png" alt="CRM Email Action Layout" style="max-width: 40%;"  />
</a>

## Creating CRM Email & Email Asset Records

To create _CRM Email_ records:

  1. Navigate to the **Modular Content** tab or to **Business Admin > Objects > Content Modules**.
  2. Click **Create**.
  3. If your Vault uses multiple _Content Module_ object types, select **CRM Email** in the _Content Module Type_ drop-down. 
  4. Select a **Primary Country**.
  5. Enter a **Description**. The _Description_ cannot exceed 5000 characters. Click <i class="far fa-external-link-alt"></i> to expand the field.
  6. Select a **Primary Product**.
  7. Click **Save**, or click **Save + Continue** to create another _CRM Email_ record.

To create _Email Asset_ records:

  1. Open a _CRM Email_ module.
  2. Click <i class="far fa-pencil-alt"></i> to edit the module.
  3. Click **+ Email Asset** to add the relevant _Content_ field. You can select the appropriate _Content Type_ in the dialog, but the text cannot exceed 5,000 characters. Click <i class="far fa-plus-circle"></i> to expand the field.
  4. To remove an asset, click the **X** icon.
  5. To reorder assets, drag and drop the cards.
  6. When finished adding assets, click **Save**.

As with other _Content Module_ object types, you can add a maximum of 100 _Email Assets_ per _Content Module_ by default. You can contact Veeva Product Support to raise this limit.

## Creating CRM Email Combinations

Content creators can define _Combination_ records to specify which content cells can be selected, and when. Users can select from all content cells in the _Combination_ when composing an email. 

To create a _Combination_ for a _CRM Email_ module:

  1. Open a _CRM Email_ module.
  2. Click <i class="far fa-plus-circle"></i> next to _Combinations_ in the left navigation panel.
  3. Enter a **Description**.
  4. Click **Continue**.

Once you create the _Combination_ record, you can begin adding _Assets_. By default, Vault selects all assets for inclusion. To manually select assets, clear the **Selected** checkbox and select any applicable assets. Click **Save** to finish editing the _Combination_. Vault creates _Combinations_ in the _Pending_ state. 

You can view _Combinations_ by selecting from the list in the left navigation panel. While viewing a _Combination_, you can click <i class="far fa-pencil-alt"></i> to edit the _Combination_ or <i class="far fa-trash-alt"></i> to delete the record. 

To open non- _Pending_ state _Combination_ records in a mini-browser window, click <i class="far fa-external-link-alt"></i>. From there, you can edit the record and move the _Combination_ through the _Content Module Combinations Lifecycle_. 

## Configuring CRM Email Previews

When configured, you can perform the **Generate Preview** action, allowing you to generate HTML previews for _CRM Email_ modules in PromoMats by combining a _CRM Email_ module and an _Email Template_. 

The _Generate Preview_ action is available on all states of the _Content Module_ object lifecycle. By default, <a href="/en/gr/47850/#Atomic_Security_Actions">Atomic Security</a>
 allows all Vault users to execute this action. You can perform this action from the _CRM Email_ module record in **Business Admin** or the the **Modular Content** tab by clicking the **Actions** menu.

Vault displays a notification when the preview link is ready. Vault generates a maximum of 20 previews per _CRM Email_ module. Previews are user-specific and cannot be shared. Previews are valid for 24 hours. You can also click **Show Preview** to reopen the preview if the previously-generated preview is still valid.

When generating a preview, you must first select an _Email Template_. Vault displays available templates based on the following conditions:

  * The _Content Module_ (`content_module__v`) document field includes the record _ID_ of the _Content Module_ you are attempting to preview
  * The _Document Type_ is _Email Template_ (`email_template__v`)
  * The _Email Template_ document is in the _Draft_, _Staged_, or _Approved_ state

<div class="note-border alert-info">
  <div class="alert alert-info" role="alert">
    <div><i class="far fa-info-circle"></i></div>
    <div class="alert-text">
      <p><strong>Note</strong>: Any CSS added to the <em>Email Template</em> to style each inserted row are not currently rendered in the preview; however, they are rendered in the final email constructed by the Email Builder.</p>
    </div>
  </div>
</div>



<a href="https://platform.veevavault.help/assets/images/Generate_Email_Preview_CRM_24r13.png" data-lightbox="Generate_Email_Preview_CRM_24r13.png" data-title="" data-alt="CRM Email Module preview">
  <img class="docimage" src="https://platform.veevavault.help/assets/images/Generate_Email_Preview_CRM_24r13.png" alt="CRM Email Module preview" style="max-width: 40%;"  />
</a>

### Generating Content Module Combination Previews

If your Vault contains active _Content Module Combination_ records on the _Content Module_, Vault only generates previews of the _Combinations_ defined, rather than allowing previews at the _Content Module_ level. 

In Veeva CRM, _Content Module Combinations_ specify rules.

<div class="note-border alert-info">
  <div class="alert alert-info" role="alert">
    <div><i class="far fa-info-circle"></i></div>
    <div class="alert-text">
      <p><strong>Note</strong>: If your Vault contains active <em>Content Module Combinations</em>, Vault does not display the <em>Generate Preview</em> button on an individual <em>Content Module</em>. The <em>Generate Preview</em> button is only displayed on a <em>Content Module Combination</em>.</p>
    </div>
  </div>
</div>



### Generation Logic

When generating previews, Vault considers any _Content Module Assets_ available for the _Content Type_ for generated previews.  

If, for example, there are _Content Module Asset_ records in _Paragraph 1_, Vault does not generate previews without a value in _Paragraph 1._ If the module does not contain _Content Module Assets_ in _Paragraph 2_, Vault generates the preview without a value in _Paragraph 2_. 

The order of preview generation is outside in:

| Subject | Greeting | Paragraph 1 | Paragraph 2 | Paragraph 3 | Documents | Closing |
| -- | -- | -- | -- | -- | -- | -- |
| SUBJECT_1 | GREETING_1 | PARAGRAPH_1_1 | PARAGRAPH_2_1 | PARAGRAPH_3_1 | DOCUMENT_1 | CLOSING_1 |
| SUBJECT_2 | GREETING_2 | PARAGRAPH_1_2 | PARAGRAPH_2_2 | PARAGRAPH_3_2 | DOCUMENT_2 | CLOSING_2 |

Generated previews contain the following content:

| Version | Subject | Greeting | Paragraph 1     | Paragraph 2     | Paragraph 3     | Documents   | Closing    |
| ----------- | ----------- | ------------ | ------------------- | ------------------- | ------------------- | --------------- | -------------- |
| 1           | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_1     | PARAGRAPH\_3\_1     | DOCUMENT\_1     | CLOSING\_1     |
| 2           | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_1     | PARAGRAPH\_3\_1     | DOCUMENT\_1     | **CLOSING\_2** |
| 3           | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_1     | PARAGRAPH\_3\_1     | **DOCUMENT\_2** | **CLOSING\_1** |
| 4           | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_1     | PARAGRAPH\_3\_1     | DOCUMENT\_2     | **CLOSING\_2** |
| 5           | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_1     | **PARAGRAPH\_3\_2** | DOCUMENT\_1     | **CLOSING\_1** |
| 6           | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_1     | PARAGRAPH\_3\_2     | DOCUMENT\_1     | **CLOSING\_2** |
| 7           | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_1     | PARAGRAPH\_3\_2     | **DOCUMENT\_2** | **CLOSING\_1** |
| 8           | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_1     | PARAGRAPH\_3\_2     | DOCUMENT\_2     | **CLOSING\_2** |
| 9           | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | **PARAGRAPH\_2\_2** | **PARAGRAPH\_3\_1** | **DOCUMENT\_1** | **CLOSING\_1** |
| 10          | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_2     | PARAGRAPH\_3\_1     | DOCUMENT\_1     | **CLOSING\_2** |
| 11          | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_2     | PARAGRAPH\_3\_1     | **DOCUMENT\_2** | **CLOSING\_1** |
| 12          | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_2     | PARAGRAPH\_3\_1     | DOCUMENT\_2     | **CLOSING\_2** |
| 13          | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_2     | **PARAGRAPH\_3\_2** | **DOCUMENT\_1** | **CLOSING\_1** |
| 14          | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_2     | PARAGRAPH\_3\_2     | DOCUMENT\_1     | **CLOSING\_2** |
| 15          | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_2     | PARAGRAPH\_3\_2     | **DOCUMENT\_2** | **CLOSING\_1** |
| 16          | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_1     | PARAGRAPH\_2\_2     | PARAGRAPH\_3\_2     | DOCUMENT\_2     | **CLOSING\_2** |
| 17          | SUBJECT\_1  | GREETING\_1  | **PARAGRAPH\_1\_2** | **PARAGRAPH\_2\_1** | **PARAGRAPH\_3\_1** | **DOCUMENT\_1** | **CLOSING\_1** |
| 18          | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_2     | PARAGRAPH\_2\_1     | PARAGRAPH\_3\_1     | DOCUMENT\_1     | **CLOSING\_2** |
| 19          | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_2     | PARAGRAPH\_2\_1     | PARAGRAPH\_3\_1     | **DOCUMENT\_2** | **CLOSING\_1** |
| 20          | SUBJECT\_1  | GREETING\_1  | PARAGRAPH\_1\_2     | PARAGRAPH\_2\_1     | PARAGRAPH\_3\_1     | DOCUMENT\_2     | **CLOSING\_2** |

### Troubleshooting

| Error Message  | Explanation |
| -- | -- |
| Selected document is not supported. Please only use .html or .htm source files. | The _Email Template_ is not an .html or .htm source file. |
| Selected document is not supported. Please only use .html or .htm source files. | The _Email Fragment_ is not an .html or .htm source file. |
| Unable to create _Email Asset_. Please select an _Email Fragment_. | When adding a document, the document type must be _Email Fragment_. |
| _Content Module Combinations_ are not valid. Please review _Combinations_ to ensure all _Content Types_ are included. | The _Content Module Combination_ does not include _Content Module Assets_ for each _Content Type_ defined in the _Content Module._ |
| Only bold, italics, underline, hyperlink, and color are allowed. When text is copied, paste as plain text (for example, using Ctrl+Shift+V or Cmd+Shift+V) and then reapply the allowed styles. | The Email Builder only supports the following HTML formats: Bold, Italics, Underline, Hyperlinks, Color, and Approved Email <a class="external-link " href="https://crmhelp.veeva.com/doc/Content/CRM_topics/Multichannel/ApprovedEmail/ManageCreateContent/CreatingContent/ConfigTokens.htm" target="_blank" rel="noopener">merge tokens and standard tokens<i class="fa fa-external-link" aria-hidden="true"></i></a> such as `{{accFname}}`, `{{userName}}`, and `{{userPhoto}}`. <br><br>Avoid copying and pasting from other sources when populating your content cell. |

## Copying CRM Email Records

Ensure that <a href="/en/gr/32218/#hierarchical-copy">hierarchical copy</a>
 is enabled for _Content Module Assets_. This allows you to copy both the _Content Module_ and _Content Module Assets (Email Assets)_ all in one action.

<div class="note-border alert-info">
  <div class="alert alert-info" role="alert">
    <div><i class="far fa-info-circle"></i></div>
    <div class="alert-text">
      <p><strong>Note</strong>: <em>Content Module Combinations</em> cannot currently be copied when copying a <em>Content Module</em>. <em>Combinations</em> must be manually rebuilt in the copied <em>Content Module</em> afterwards.</p>
    </div>
  </div>
</div>



## Related Permissions

You must have the _Annotate_ document role permission to create annotations. To create link annotations, you also need the _Edit Relationships_ document role permission.

You must have the _Object: Content Module: Read_ and _Object: Content Module Asset: Read_ permissions to view module and asset records. To download _Content Modules_, you must have these permissions along with _Object: Text Assets: Read_, _Object: Content Module Rulesets: Read_, and _Object: Ruleset Rules: Read_. You must also have _View Document_, _View Content_, and _Download Source_ permissions on documents linked within image and data _Content Module Asset Types_.

You must have the _Object: Content Module Combination: Create_, _Edit_ and _Object: Content Module Asset Combination: Create_, _Edit_ permissions to create _CRM Email Combinations_.

You must have the following permissions to generate email previews:

  * _Read_ on the _CRM Email_ type of the _Content Module_ object
  * _Read_ on the _Email Asset_ type of the _Content Module Asset_ object
  * _Read_ on the _Content Type, Asset,_ and _Content_ fields on the _Content Module Asset_ object
  * _Object: Content Module Combination: Read_
  * _Object: Content Module Asset Combination: Read_
  * _View_ on the email template used to generate the preview
  * _Read_ on the _Subject, Name, Format,_ and _Content Module_ document fields
  * <a href="/en/gr/47850/#Atomic_Security_Actions">Atomic Security: _Execute_</a>
 on the _Preview Content Module_ user action

