# Setting Up Automated CoA Email Intake (QMS)

Users and external parties can use this option to email single or multi-batch documents for existing <a href="/en/gr/69952/">_COA Inspection_ records</a> or to create new _COA Inspection_ records from automated email validation and data ingestion. After Vault receives emailed documents, Vault verifies if the files are valid to attach to a record according to certain parameters and ingests the data. You must set up this feature to allow users, _External Collaborators_, and external parties to upload CoA documents to Vault for record analysis.

<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>: This feature is currently available only to Early Adopters. Contact your Veeva Representative for more details.</p>
    </div>
  </div>
</div>



## About CoA Email Intake Types {#about}

There are two (2) types of email intake processors, which require different setup instructions:

* **[Vault Interaction with Email Intake][1]**: Set up this email intake for users, which include the _External Collaborators_, to receive an email from Vault for an assigned task to submit single or multi-batch CoA files. For external users to interact directly with Vault, ensure you've configured the external user as an <a href="/en/gr/76844/">_External Collaborator_</a> to assign and notify any workflow tasks.
* **[External Interaction with Email Intake][2]**: Set up this email intake by specifying inbound email addresses to allow specific external parties to send single or multi-batch CoA attachments by email to Vault, unprompted by Vault. This type of email intake does not require initial external user setup as Vault interaction does, and only requires your user to have access to the inbound email address.

### Vault Interaction with Email Intake {#about-intake}

For Vault interaction with CoA email intake, when an _External Collaborator_ receives an [email for CoA submission][3], the user can upload one (1) or more single or multi-batch CoA files to a _COA Inspection_ record, or multiple relevant CoA files to subsequent copies of the initial _COA Inspection_ record by email reply. Vault does one (1) of the following when an _External Collaborator_ sends a reply to validate the incoming emails and ingest any data found in each attachment:

* If an _External Collaborator_ emails one (1) valid single or multi-batch CoA file for intake, Vault automatically attaches that file to the matching record name (as defined in the email subject line) and sends the _External Collaborator_ a success email reply.
  * Vault updates the lifecycle state for the matching record.
* If an _External Collaborator_ emails more than one (1) valid single or multi-batch CoA file for intake, Vault automatically attaches the first valid file to the matching record name (as defined in the email subject line) as the initial record and sends a success email reply.
  * Vault verifies the remaining number of valid CoA files and invokes the standard <a href="/en/gr/32218/">_Copy Record_ action</a> (a shallow copy) until there is a matching record for each valid file. 
  * Each subsequent record copied has the initial record name as the _Source Inspection_ value with all valid available fields and their values copied to the new record.
  * Once Vault copies the valid amount of records, Vault attaches the remaining subsequent files to each record copied.
  * Vault updates the lifecycle state for each copied record.
* If an _External Collaborator_ emails zero (0) valid single or multi-batch CoA files for intake, Vault sends a failure email reply for each error type detected.
* If an _External Collaborator_ emails a mixture of valid and invalid single or multi-batch CoA files for intake, Vault handles all valid files according to the first or second criteria and handles all invalid files according to the third criteria. 
  * Vault sends a single success email reply for all valid files and failure email replies for each error type detected. 
  * Any CoA files with the same error types are grouped into each error type email reply.

The CoA file must be in the PNG, JPG, or JPEG file types for Vault to automate the email intake feature.

### External Interaction with Email Intake {#about-external}

For external interaction with CoA email intake, your user can upload one (1) or more related single or multi-batch CoA files to Vault to trigger _COA Inspection_ record creation. These CoA files are compiled from your organization's external parties, such as suppliers. Unlike [Vault interaction with email intake][1], external interaction allows the user to send CoA files as long as you've configured a <a href="/en/gr/45776/">Vault Java SDK</a> extension for the inbound email address. Vault does one (1) of the following when a user sends an email to a specified Vault inbound email address for file validation and data ingestion:

* If the user emails one (1) or more valid single or multi-batch CoA files for intake, Vault creates a _COA Inspection_ record for each valid attachment.
  * Vault classifies the attachments as _Documents_.
  * If there is a _Purchase Order_ number defined in the email subject line, Vault may associate the following related records: _Inspection Plan_, _Material_, and _Purchase Order Line Item_ records. Including the _Purchase Order_ number allows Vault to automatically analyze the CoA file after validation and ingestion, if configured.
  * For each newly-created _COA Inspection_ record, Vault populates the fields with data values from the custom Vault Java SDK extension for all records.
  * Vault updates the lifecycle state for each newly-created record and sets the _COA Ingestion Status_ field to "Automatic".
* If the user emails zero (0) valid single or multi-batch CoA files for intake, Vault sends a failure email reply with each error type detected.
* If the user emails a mixture of valid and invalid single or multi-batch CoA files for intake, Vault handles all valid files according to the first criteria and handles all the invalid files according to the second criteria.
  * Only invalid files will be mentioned in the failure email reply with each error type detected.

The CoA file must be in the PNG, JPG, or JPEG file types for Vault to automate the email intake feature.

## Setting Up Email Intake for CoA Uploads {#setup}

Ensure you follow the appropriate steps for the following email intake types:

* **[Setting Up Vault Interaction][4]**
* **[Setting Up External Interaction][5]**

### Setting Up Vault Interaction {#setup-intake}

To allow internal and external users to upload single or multi-batch CoA files using email intake to an existing _COA Inspection_ and copied records of a source _COA Inspection_, you must set up the following:

* Enable <a href="/en/gr/33946/">DAC</a> for the _Inspection_ object. When _External Collaborators_ trigger Vault to copy records from a _Source Inspection_ for multiple valid CoA files, the _Sharing Settings_, such as DAC configurations and manual assignments, are also copied over to the new records as part of the trigger.
* Create a <a href="/en/gr/46534/#about-the-person-object">_Person_ record</a> and ensure the _Email_ field contains your organization's Reply-To email address for CoA email intake. For example, your Reply-To email address may be "coa@organization.com".
* Navigate to **Admin > Settings > Application Settings > Inspection Management** and select the _Enable Automated COA Analysis_ checkbox. Enter the same Reply-To email address used for the _Person_ record. Setting up the Reply-To email allows _External Collaborators_ to reply to your organization's specified email address instead of the generic Vault email address. This ensures that the CoA file is uploaded to the correct organization and the correct record.
* Create an <a href="/en/gr/74285/">inbound email address</a> for users to email to for automated CoA email intake. When creating the inbound email address, ensure you select **COA Email Intake** for your _Email Processor_ and select **All Users in this Vault** for _Allowed Senders_.
* Configure <a href="/en/gr/76844/">External Collaboration Management</a> on the _Inspection_ object for _COA Inspection_ as the target object. When _External Collaborators_ trigger Vault to copy records from a _Source Inspection_ for multiple valid CoA files, the _Sharing Settings_, such as _External Collaborator_ values, are also copied over to the new records as part of the trigger.
* Create an object <a href="/en/gr/33550/">workflow</a> or modify the existing _Inspection_ object workflow, and include _Send CoA Upload Workflow Task Email_ as your _System Action_ step with _COA Submission_ as your _[Notification Template][3]_.
* Optional: When configuring the _COA Uploaded_ and _COA Uploaded with Missing Data_ lifecycle states for the _Inspection Lifecycle_, we recommend adding the <a href="/en/gr/69952/#config-coa-actions">_Analyze COA_</a> entry action to trigger Vault to analyze the emailed CoA file attached to the record.

### Setting Up External Interaction {#setup-external}

To allow your organization's user to upload single or multi-batch CoA files (compiled from external parties) and create new _COA Inspection_ records for each file outside of Vault, you must set up the following to allow external interaction with Vault's email intake feature:

* Set up your email intake for external interaction by importing a <a href="/en/gr/36919/#import">configuration migration inbound package</a>. Contact your Veeva Representative to access a VPK to deploy the custom Vault Java SDK configuration package. Implementing a custom SDK package allows your Vault to extract information from an incoming email and its attachments, and create _COA Inspection_ records for each valid attachment detected. See <a class="external-link " href="https://developer.veevavault.com/sdk/#QualityOne_QMS" target="_blank" rel="noopener">Vault Java SDK in the Developer Portal<i class="fa fa-external-link" aria-hidden="true"></i></a> for more details.
* Navigate to **Admin > Configuration > Vault Java SDK > QualityOne COA Email Intake Handlers** and ensure that the custom SDK implementation's _Operational Status_ is set to "Enabled". Contact your Veeva Representative if your custom SDK implementation is missing or is disabled.
* Navigate to **Admin > Settings > Application Settings > Inspection Management** and select the appropriate **User Group for COA Email Intake Notification** options in the drop-down.
* Create an <a href="/en/gr/74285/">inbound email address</a> for users to email for automated CoA email intake. When creating the inbound email address, ensure you do the following:
    * Enter the **Email Address** that matches the inbound email address defined in the custom SDK implementation. If you're unsure of what the email address should be, contact your Veeva Representative for assistance.
    * Select **Supplier Initiated COA Email Intake** for the _Email Processor_.
    * Select **All Users in this Vault** for the _Allowed Senders_.
* Optional: When configuring the _COA Uploaded_ and _COA Uploaded with Missing Data_ lifecycle states for the _Inspection Lifecycle_, we recommend adding the <a href="/en/gr/69952/#config-coa-actions">_Analyze COA_</a> entry action to trigger Vault to analyze the emailed CoA file attached to the record.

## Configuring Notification Templates {#notification}

There are several email notification templates for the _COA Inspection_ object you can <a href="/en/gr/2157/">customize</a> to which Vault automatically sends to _External Collaborators_ assigned on a _COA Inspection_ record and when Vault receives an external email from an approved email address.

Depending on your configuration for [Vault interaction][1], you may have a _System Action_ step that triggers an email notification to the assigned _External Collaborator_ requesting a CoA file submission. Other Vault interaction email notification templates are sent to _External Collaborators_ and workflow owners depending on the validity of the email reply; whether the CoA file was received by Vault, the CoA file is submitted to the record, or there was a failure when sending the file in the email.

For external interaction email notification templates, Vault sends them depending on the errors found in the received email; if Vault fails to upload because the files are faulty, the files cannot be ingested, Vault cannot create a _COA Inspection_ record for certain CoA files, or the Vault receiving the email is missing important [Admin setup][5].

### Notification Templates {#notif-template}

Vault uses the following notification templates for email intake:

* Vault Interaction
  * _CoA Submission_ (`coa_submission__v`)
  * _Success: CoA Received_ (`success_coa_received__v`)
  * _CoA Email: Failed to upload the file_ (`coa_email_fail_upload_file__v`)
* External Interaction
  * _COA Email: Failed to Ingest Attachment_ (`coa_email_failed_to_ingest_attachment__v`)
  * _COA Email: No Files Ingested_ (`coa_email_no_files_ingested__v`)
  * _COA Email Processor Cannot Create Record_ (`coa_email_processor_cannot_create_record__v`)
  * _COA Missing Material Feature Flag Config_ (`coa_missing_material_ff_config__v`)

### Message Template Tokens {#message-temp-token}

QualityOne Vaults can use additional token support using standard <a href="/en/gr/2157/">object notification configurations</a>. <a href="/en/gr/6382/">Tokens</a> are pieces of text that are replaced at the time the notification is used. To configure the notification templates, use tokens within the email content for document notification templates.

[0]: #about
[1]: #about-intake
[2]: #about-external
[3]: #notification
[4]: #setup-intake
[5]: #setup-external