This guide outlines how to connect to an EWS Outlook on-premises data source, ingest its content, and configure it for retrieval using a Knowledge Graph tool.

## Connect to EWS Outlook On-Premises

Follow these steps to set up your EWS Outlook on-premises data source:

1.  Navigate to the **Data Sources Library**.
2.  Select **EWS Outlook on premises** from the available options.
3.  Provide the necessary authentication details:
    *   **EWS URL**: This URL is typically provided by your system administrator.
    *   **Username**: Your Outlook username.
    *   **Password**: Your Outlook password.
    *   **Domain**: Your organization's domain.
    *   **Email Address**: The email address of the mailbox you wish to ingest.
4.  Configure **Ingestion Settings**:
    > 💡 **Note**: Default values are preselected. For more details on advanced ingestion options, refer to the [Ingestion Settings documentation](https://explore.airia.com/integrations/Data-Source-Connectors/Ingestion%20settings).
5.  Click **Next** to view the folder hierarchy of the selected mailbox. Select the specific folders you want to ingest.
6.  Click **Done** to initiate the ingestion process.

You can monitor the ingestion status and view the ingested documents in the data source's file list view.

> 💡 **Note**: Emails and their attachments will be ingested as separate files within the file list view.

## Utilize EWS Data with the Knowledge Graph

Once your data is ingested, our Knowledge Graph captures relations between emails, threads, senders, receivers, and attachments.

### View Your Knowledge Graph

You can visualize the extracted relationships and schema:

1.  Go to **Edit data source** for your EWS Outlook on-premises connection.
2.  Scroll down to the **Knowledge Graph** section.
3.  Click **View Graph**.

Here, you can examine all created nodes and relations in both a **schema view** and a **graphic visualization** of the knowledge graph.

### Configure for Retrieval

To query and utilize this structured data, you need to create a tool in your project:

1.  Go to the **Tools** tab in your project.
2.  Select **New tool**.
3.  Search for and select the **Query Graph DB** tool.
4.  From the dropdown menu, select the name of the EWS Outlook on-premises data source you just created to configure the tool for retrieval.
5.  Attach this tool to your LLM in the Agent to enable querying of your EWS data.

## Validate EWS Configuration

This section describes how to confirm that the EWS endpoint is correctly configured on your Exchange server, ensuring it's reachable and prompts for authentication (Windows/NTLM/Negotiate). This verifies that the EWS virtual directory is online and protected.

### 1. Locate the EWS Virtual Directory in IIS

1.  Log on to the Exchange server.
2.  Open **Internet Information Services (IIS) Manager**.
3.  Expand **Sites**.
    You will typically find two EWS locations:
    *   **Default Web Site** → **EWS** (This is the common client-facing endpoint used by external applications.)
    *   **Exchange Back End** → **EWS** (This is an internal endpoint often used by Exchange services, usually on port 444.)
    > 💡 **Tip**: When validating for external applications or clients, prioritize the `Default Web Site` → `EWS` endpoint.

### 2. Browse the EWS Endpoint (from the server)

#### A. Validate the "Default Web Site" EWS Endpoint

In a browser on the Exchange server, navigate to:
`https://localhost/EWS/Exchange.asmx`

**Expected result:**
The browser should prompt for credentials (or display an HTTP 401 Unauthorized response followed by an authentication prompt). After successfully authenticating, you might see a simple "Service" page or an EWS service description page. This indicates that EWS is running and is properly secured.

#### B. (Optional) Validate the "Exchange Back End" EWS Endpoint

If you need to specifically test the backend endpoint, navigate to:
`https://localhost:444/EWS/Exchange.asmx`

**Expected result:**
You should observe the same behavior as above: the endpoint should require authentication and should not allow anonymous access.

### 3. Interpreting Validation Results

Review the following indicators to determine if your EWS configuration is correct:

> ✅ **Success: Good Signs**
> *   You receive a credential prompt (e.g., for Windows authentication).
> *   You receive an `HTTP 401` status code when not authenticated (this is normal for a protected EWS endpoint).
> *   After entering valid credentials, the page loads successfully (displaying a service page or WSDL).

> ⚠️ **Warning: Bad Signs**
> *   **`404 Not Found`**: The specified path is incorrect, or the virtual directory is not mapped properly.
> *   **`500 Internal Server Error`** or **`503 Service Unavailable`**: This indicates an issue with the application pool or a core Exchange service.
> *   **Redirects unexpectedly to OWA/ECP**: You might be hitting the wrong site/URL, or a proxy rewrite rule is interfering.
> *   **Loads without any credential prompt**: Anonymous authentication might be enabled for EWS, which is generally not expected or recommended in most Exchange setups.
