# Exchange Adapter

This adapter represents an Exchange adapter for fetching folder and email fetching.

## Configuration

Exchange configuration defines OAuth parameters.

<figure><img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8HTRblOKav_qm4KEx6-887967055%2Fuploads%2FytHvXyBwOcgZmbGcvIT5%2Fimage.png?alt=media&#x26;token=e6cc984f-a2b5-496b-95e1-67ee1bde5100" alt="" width="140"><figcaption></figcaption></figure>

### Step: Debug

The Debug step requests whether a debug token should be used (instead of authentication).

| Parameter           | Type    | Format | Required | Remarks                                           |
| ------------------- | ------- | ------ | -------- | ------------------------------------------------- |
| DebugAccessToken    | String  |        | No       | The debug access token to use.                    |
| DebugUseAccessToken | Boolean |        | Yes      | Determines whether to use the debug access token. |

### Step: OAuth

The OAuth step requests OAuth parameters to use for authentication.

| Parameter              | Type   | Format | Required | Remarks                                                                |
| ---------------------- | ------ | ------ | -------- | ---------------------------------------------------------------------- |
| OAuthApplicationId     | String |        | No       | The ID of the application registered for Exchange.                     |
| OAuthApplicationSecret | String |        | No       | The secret of the application registered for Exchange.                 |
| OAuthCallbackUrl       | String | URL    | No       | The callback URL after OAuth authentication is done.                   |
| OAuthTenantId          | String |        | No       | The tenet ID of the Exchange or ‘common’ for multi-tenant application. |

## Authentication

Exchange authentication is either done through OAuth for the cloud location or ‘Basic Authentication’ for on-premise locations.

<figure><img src="https://2608258621-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M8HTRblOKav_qm4KEx6-887967055%2Fuploads%2FfawrmNAhHeEhKCa5P8wm%2Fimage.png?alt=media&#x26;token=3c8cf90d-66ae-450b-9ab9-c5508c8e4d74" alt=""><figcaption></figcaption></figure>

### Step: Email

The Email step requests the email address to detect the location of the Exchange server.

| Parameter                | Type   | Format                                | Required | Remarks |
| ------------------------ | ------ | ------------------------------------- | -------- | ------- |
| EmailAddress             | String | <p>Email address                      |          |         |
| <br>(<john@doe.com>)</p> | Yes    | The email address to authenticate to. |          |         |

### Step: Location

The Location step requests the location to authenticate to when the location could not be found.

| Parameter | Type   | Format                | Required | Remarks                              |
| --------- | ------ | --------------------- | -------- | ------------------------------------ |
| Location  | String | “Cloud”, “On Premise” | Yes      | The location of the Exchange server. |

### Step: Cloud

The Cloud step requests the URLs of the Exchange server in the cloud.

| Parameter       | Type   | Format | Required | Remarks                                                                                                                                                                                          |
| --------------- | ------ | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| AutodiscoverUrl | String | URL    | Yes      | The auto-discover URL of the Exchange server. Defaults to “[https://outlook.office365.com/autodiscover/autodiscover.svc”](https://outlook.office365.com/autodiscover/autodiscover.svc%E2%80%9D). |
| ServiceUrl      | String | URL    | Yes      | The EWS URL of the Exchange server. Defaults to “[https://outlook.office365.com/EWS/Exchange.asmx”](https://outlook.office365.com/EWS/Exchange.asmx%E2%80%9D).                                   |

### Step: OAuth

The OAuth step authenticates the user to the Exchange server through OAuth2.

### Step: OnPremise

The OnPremise step requests the version and URLs of the Exchange server on-premise.

| Parameter        | Type   | Format                                                                                                                                             | Required | Remarks                                                  |
| ---------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------------------------------------------------------- |
| AutodiscoverUrl  | String | URL                                                                                                                                                | Yes      | The auto-discover URL of the Exchange server.            |
| ServiceUrl       | String | URL                                                                                                                                                | Yes      | The EWS URL of the Exchange server.                      |
| OnPremiseVersion | String | "Exchange2016", "Exchange2015", "Exchange2013\_SP1", "Exchange2013", "Exchange2010\_SP2", "Exchange2010\_SP1", "Exchange2010", "Exchange2007\_SP1” | Yes      | The Exchange server version (for compatibility reasons). |

### Step: Basic Authentication

The Basic Authentication step requests the username and password to authenticate to the Exchange server.

| Parameter | Type   | Format | Required | Remarks                             |
| --------- | ------ | ------ | -------- | ----------------------------------- |
| Domain    | String |        | Yes      | The domain of the user’s account.   |
| Password  | String |        | Yes      | The password of the user’s account. |
| UserName  | String |        | Yes      | The username of the user’s account. |

## Class: Attachment

Represents an attachment of an email message.

| Field            | Type     | Format                       | Remarks                                                           |
| ---------------- | -------- | ---------------------------- | ----------------------------------------------------------------- |
| ContentId        | String   |                              | The content Id of the attachment.                                 |
| ContentLocation  | String   |                              | The content location of the attachment.                           |
| ContentType      | String   |                              | The content type of the attachment.                               |
| EmailId          | String   |                              | The ID of the email message.                                      |
| Filesize         | Integer  |                              | The size of the attachment.                                       |
| Id               | String   | \<Attachment-ID>;\<Email-ID> | The ID of the attachment appended by the ID of the email message. |
| IsInline         | Boolean  |                              | A value indicating whether this is an inline attachment.          |
| LastModifiedTime | DateTime |                              | The date and time when this attachment was last modified.         |
| Name             | String   |                              | The name of the file the attachment is linked to.                 |

## Class: Email

Represents an email message.

### Action: Create

Creates an email in the ‘Drafts’ folder of the mailbox identified by the **MailboxId** parameter or default mailbox if not provided.

| Parameter                               | Type    | Format                                                                               | Required | Remarks                                                                                          |
| --------------------------------------- | ------- | ------------------------------------------------------------------------------------ | -------- | ------------------------------------------------------------------------------------------------ |
| BccRecipients                           | String  | <p>Email addresses                                                                   |          |                                                                                                  |
| <br>(<john@doe.com>;<jane@doe.com>)</p> | No      | The list of Bcc recipients for the email message.                                    |          |                                                                                                  |
| Body                                    | String  |                                                                                      | No       | The text of the message body.                                                                    |
| BodyType                                | String  | “Test”, “HTML”                                                                       | No       | The type of the message body's text. Defaults to “HTML”.                                         |
| CcRecipients                            | String  | <p>Email addresses                                                                   |          |                                                                                                  |
| <br>(<john@doe.com>;<jane@doe.com>)</p> | No      | The list of Cc recipients for the email message.                                     |          |                                                                                                  |
| FromAddress                             | String  | <p>Email address                                                                     |          |                                                                                                  |
| <br>(<john@doe.com>)</p>                | No      | Used as the "on behalf" sender of the email message. Used in favor of **MailboxId**. |          |                                                                                                  |
| Importance                              | String  | “Low”, “Normal”, “High”                                                              | No       | The importance of this email message. Defaults to “Normal”.                                      |
| IsDeliveryReceiptRequested              | Boolean |                                                                                      | No       | A value indicating whether a read receipt is requested for the email message. Defaults to false. |
| IsReadReceiptRequested                  | Boolean |                                                                                      | No       | A value indicating whether a read receipt is requested for the email message.                    |
| MailboxId                               | String  | <p>Email address                                                                     |          |                                                                                                  |
| <br>(<john@doe.com>)</p>                | No      | Used as the "on behalf" sender of the email message.                                 |          |                                                                                                  |
| Sensitivity                             | String  | “Normal”, “Personal”, “Private”, “Confidential”                                      | No       | The sensitivity of this email message.                                                           |
| Subject                                 | String  |                                                                                      |          | The subject of the message.                                                                      |
| ToRecipients                            | String  | <p>Email addresses                                                                   |          |                                                                                                  |
| <br>(<john@doe.com>;<jane@doe.com>)</p> | No      | The list of To recipients for the email message.                                     |          |                                                                                                  |

## Logging

| Type                                      | Remarks                                         |
| ----------------------------------------- | ----------------------------------------------- |
| Tivity.App.Plugins.Microsoft.Exchange     | The base logging type for the Exchange adapter. |
| Tivity.App.Plugins.Microsoft.Exchange.EWS | Traces EWS communication.                       |
