# How to Restore Archived Cases with Emails and File Attachments

## ![](https://646917531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Focom3JROuDKOidclKbQx%2Fuploads%2Fgit-blob-3f6faa4230b72167926fbc0a31dd17dc7d74581d%2FSummary2-Small-Icon.svg?alt=media) Overview

Restoring archived objects that include emails and file attachments requires properly archiving the original case objects along with their related emails and files. This guide details the process of successfully archiving and restoring **Case** objects containing **Emails** and **file attachments** using the Backup & Archive application.

{% hint style="info" %}
The article uses the **Case** object as an example, but any object with an email and a file can be used.
{% endhint %}

### Prerequistes

The following conditions are required to complete the instructions in the article. Each is explained in more detail in the sections below.

* [#create-archive-template-for-emails-and-file-attachments](#create-archive-template-for-emails-and-file-attachments "mention")
* [#assign-the-update-email-messages-permission](#assign-the-update-email-messages-permission "mention")

To complete this example, ensure you are familiar with the following actions in Backup & Archive:

* Create an Archive: [creating-a-templated-archive](https://docs.flosum.com/backup-and-archive/backup-and-archive/archives/creating-a-templated-archive "mention")
* Create Restore Job: [creating-an-archive-restore-job-preparation](https://docs.flosum.com/backup-and-archive/restore/prepare-restore/creating-an-archive-restore-job-preparation "mention")
* Execute Restore Job: [running-a-restore-job-execution](https://docs.flosum.com/backup-and-archive/restore/execute-restore/running-a-restore-job-execution "mention")

## Create Archive Template for Emails and File Attachments

To ensure all related records and attachments are archived and restorable, the archive template must be configured with proper parent-child relationships. See the basic structure below, along with a screenshot of an example Archive Template.

* **Case** - Parent Object
  * **Content Document** - Files related to the Case object
  * **Email Message** - Emails related to the Case object
    * **Content Document** - Files related to the Email Messages object

<div align="left"><figure><img src="https://646917531-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Focom3JROuDKOidclKbQx%2Fuploads%2FL1zqoKFEperCUbflHOsv%2FHowToRestoreArchivedEmailAndFile-Archive-01.png?alt=media&#x26;token=96f44c3e-d023-4533-bd39-e894fe078ce8" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="warning" %}

#### Important

Files attached to **Email Message** objects appear in the **Case** object's Files related list due to the internal **Combined Attachment** object. Here are key points to note:

* **Not Directly Related:** The **Combined Attachment** object is not directly related to the **Case** object.
* **API Restrictions:** It is not queryable or restorable via API.
* **Restore Caution:** If you don't include the **Content Document** object under **Email Message** in the archive template, email attachments will neither be backed up nor restored.
  {% endhint %}

## Assign the “Update Email Messages” Permission

Restoring Email Messages with attachments requires the user performing the restore to have the **“Update Email Messages”** system permission. This is necessary to re-establish relationships between EmailMessages and files, and to update fields such as To, From, Cc, Bcc, and ContentDocument references. Follow these steps:

1. Log in to your Salesforce org.
2. Go to **Setup**
3. In **Quick Find**, search for **Permission Sets.**
4. Click **New** or open an existing permission set.
5. Navigate to **System Permissions.**
6. Click **Edit.**
7. Search for **Update Email Messages** and check the box.
8. Click **Save.**
9. Click **Manage Assignments** > **Add Assignments.**
10. Select the user who is used to connect your Salesforce org with your Flosum Cloud Apps.
11. Click **Assign.**

{% hint style="warning" %}

#### What happens without the Update Email Messages permission?

* Email records and files may be restored, but:
  * **ContentDocumentLink** relationships will not be restored.
  * **Attachments** will not appear in the related list of the restored EmailMessage.
  * Files may still exist in Salesforce, but will not be accessible from the restored email.
    {% endhint %}

## View Restored Emails and Attachments

To verify restored records:

1. Navigate to the restored **Case** record
2. In **Activity History**, find the restored email
3. Open the **EmailMessage** record
4. In the **Related** section, click on **Attachments**
5. Files attached to the email will appear here

{% hint style="warning" %}

### Why are restored email attachments not appearing on the Attachments page?

* The Notes & Attachments section uses the **CombinedAttachment** object.
  * This object cannot be created or restored via the API. (Salesforce Limitation)
  * Restored files won’t be shown in the Notes & Attachments section.
* Images are **Embedded** in the email body.
  * Embedded images are stored through CaseFeed, which is not creatable/updatable via API. (Salesforce Limitation)
  * The images are restored as files, but won’t render inline in emails.
    {% endhint %}
