# Working with Complaint Email Ingestion (QMS)

The Complaint Email Ingestion feature helps QMS customers when it is not feasible to rely solely on the manual creation of complaints, or an integration with another system to automate complaint creation. It enables customers to build an end-to-end automated complaint process by allowing organizations to [configure a Vault Email Inbox](/en/lr/61887102/) to process _Complaints_ received via email. When the _Complaint Email Inbox_ receives an email, Vault automatically creates a _Complaint_ record. 

QMS customers also have the ability to capture potential complaints, called [_Complaint Intake_ records](/en/lr/28400/), to triage in Vault before making the decision to promote them to _Complaint_ records. Vault can create a _Complaint Intake_ record via an integrated third-party system, such as a manufacturer's website, or via emails received in a configured _Complaint Email Inbox_. Users also can manually create a _Complaint Intake_ record. The _MedTech Complaint Intake_ object type is not supported for _Complaint Intake_ email ingestion.

If configured by an Admin, Vault can store the original email and any attachments on the new _Complaint_ or _Complaint Intake_ record.

If your Vault is configured to create _Complaint_ records from email, the _Complaint_ records may be either a standalone _Complaint_ object or a _Quality Event_ of the _Complaint Email_ object type. These are collectively referred to as _Complaint_ records in this article.

## Create Complaint Email Processor Execution {#email-processor-execution}

When the _Create Complaint_ email processor executes, it creates a _Complaint_ or a _Complaint Intake_ record, depending on your configuration. The email processor determines if a _Complaint_ or _Complaint Intake_ record already exists for the incoming email by checking the message ID and references in the email's header. If the processor does not find such a _Complaint_ or _Complaint Intake_ record, it creates a new _Complaint_ or _Complaint Intake_ record based on the associated _Inbound Email Address Configuration_.

Vault attempts to populate field data on the resulting _Complaint_ or _Complaint Intake_ record from the source email using the following mapping:

| Email Data         | Field on _Complaint_ or _Complaint Intake_ Record               | Description & Limitations                                                                                           |
| ------------------ | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| Original Sender    | Initial Reporter (`initial_reporter_details__v`)           | Plain text of original sender's email address                                                                       |
| From Email Address | Sender Email Address (`sender_email_address__v`)           | Plain text of sender's email address                                                                                |
| Email Sent Date    | Initial Report Date (`initial_report_date__v`)             | Date field                                                                                                          |
| Email Subject      | Title (`title__v`)                                         | Plain text of email subject, up to 150 characters by default                                                        |
| Email Body         | Email Body (`email_body__v`)                               | Special field which renders email [as described below][1]                                                                |
| Email Text         | Email Text (`email_text__v`)                               | Long text field which contains the original plain text of the Email Body                                            |
| Email Attachments  | Added to the record in the _Attachments_ section           | Original Email in EML format and [any other attachments][2].                                                             |
| Email Metadata     | Initial Contact Method (`initial_contact_method__v`)       | Set to picklist value Email (`email__v`)                                                                            |
| Email Metadata     | Vault Email Inbox Address (`vault_email_inbox_address__v`) | This is the Inbound Email Address the original email was sent to which triggered the processor to create the record |
| Email Metadata     | Message ID (`message_id__v`)                               | Message ID of the email                                                                                             |
| Email Metadata     | Root Message ID (`root_message_id__v`)                     | Original Message ID of the email                                                                                    |


### Email Body & HTML {#email-body}

Depending on your configuration, an email may create a _Complaint_ or _Complaint Intake_ record. In the _Email Body_ section or _Email Body_ field on the record's details page, Vault renders the email for viewing in its original language. In some situations, special characters may not render as they might in an email viewer. If the email content exceeds 32,000 characters, the _Email Body_ section displays a warning message in Vault and on [downloaded PDFs](/en/lr/44069/#download-as-pdf), while the _Email Body_ field displays a truncated version of the email text. You can view and download the full email in the record's _Attachments_ section.

### Attachments {#attachments}

The _Attachments_ section contains the original email file, and any files attached to the original email or any follow-up emails, up to a limit of 50 files. If an attachment has the same name and different content to an already existing attachment, Vault creates a new version of the attachment. Attachments will be processed until the [attachment limit](/en/lr/24287/) is reached. If the email processor attempts to add more than the limit, Vault sends a warning to the sender.

### Follow-up & Duplicate Processing

Sometimes a complainant replies to the original email or to an External Notification sent from Vault about an existing _Complaint_ or _Complaint Intake_ record. In these cases, the email processor recognizes that the reply email is associated with an existing _Complaint_ or _Complaint Intake_ record, and Vault does not create a new record. Instead, the reply email is associated with the original _Complaint_ or _Complaint Intake_ record.

## Processor Failures & Warnings

If the _Create Complaint_ email processor fails to create a _Complaint_ or _Complaint Intake_ record for an email, it notifies the sender of the failure using the _Email Processing: Failed_ (`qms_email_processing_failed__v`) [object message template](/en/lr/2157/). If the email processor successfully created the _Complaint_ or _Complaint Intake_ record but encountered errors, it notifies the sender using the _Email Processing: Warning_ (`qms_email_processing_warning__v`) object message template.

## Related Permissions

When Vault is configured to create _Complaint_ records of the _Complaint Email_ object type, in order to view the _Complaint Email_ records and perform triage actions on them, you require a security profile that grants you the following permissions:

* _Read_, _Create_, and _Edit_ permissions on the _Complaint Email_ object type for either the _Complaint_ or _Quality Event_ object, depending on which one your Vault utilizes.

When Vault is configured to create _Complaint_ _Intake_ records, in order to view the _Complaint Intake_ records and perform triage actions on them, you require a security profile that grants you the following permissions:

* _Read_, _Create_, and _Edit_ permissions on the _Complaint Intake_ object.

  [1]: #email-body
  [2]: #attachments
  [3]: #email-processor-execution
