# Email Integration

ProcessMaker IDP can import emails with attachments from Outlook365, process the attachments, and store them in ProcessMaker IDP. The email body text will be stored as metadata, allowing searching through the email body. After all ProcessMaker IDP actions have been completed, the email can be moved to the archive folder on the Outlook365 system.

## **Preliminary Steps**

* Access to a server to either deploy the email-importer as a WAR or in a container
* Access to the client email server (URLs, username, password, etc.)
* Connectivity to ProcessMaker IDP and the Keycloak application
* An email importer client should be created in Keycloak with necessary roles

***

## **Create Client and Roles in Keycloak**

1. Navigate to the respective realm and select create
2. Create a client with a name (e.g., emailImporter)
3. Navigate to the client, change the access type to confidential, enable Service Accounts, and click save
4. Navigate to the Credentials tab, copy and save the secret for later use
5. Navigate to the Service Account Roles tab and assign necessary roles to the email importer client

***

## **Create an Email Dossier in ProcessMaker IDP**

1. Log in to ProcessMaker IDP, click the '+' sign, and select 'New dossier'
2. Choose a dossier name and click the 'Create dossier' button
3. Select the 'Dossiers' icon and select the previously created (email) dossier. Use the 'Dossier actions' button to create the required number of sub-folders
4. Select each of the created sub-folders, click the 'info' button, copy the 'Id' and save it for later

***

## **Configuration Files**

Currently, it is only possible to maintain the configuration files outside the ProcessMaker IDP User Interface. The email importer application has two configuration files: `application.yml` and `EmailImporter.json`.

In the `application.yml` the following fields should be configured:

* ProcessMaker IDP webserver URL
* Keycloak token-uri
* Keycloak client-id (previously copied and saved in step 2 of the Keycloak configuration)
* Keycloak client-secret (previously copied and saved in step 4 of the Keycloak configuration)
* Locations config path and name to the `EmailImporter.json` file

The `EmailImporter.json` file is used by the application to configure the location of the email box(es) and their associated dossier folders in ProcessMaker IDP.

<figure><img src="https://3188697301-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7FFioLROF5EqDMa8cWdB%2Fuploads%2FXXcTHK0D2OBV2JmZFUg3%2Fimage.png?alt=media&#x26;token=8282d5ae-0955-42bb-9fbc-c43544993031" alt=""><figcaption></figcaption></figure>
