# Microsoft.Exchange.WebServices.Auth

**Kind:** Service

**Source:** `Pams/Logic/Pams.Email/Pams.Email.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`Microsoft.Exchange.WebServices.Auth` is a NuGet package dependency declared by the `Pams.Email` project for Exchange Web Services authentication. It supports the server-side email integration path, allowing `Pams.Email` to authenticate before reading or sending Exchange mailbox data.

## Diagram

```mermaid
sequenceDiagram
    participant Client
    participant PamsEmail as Pams.Email
    participant EwsAuth as Microsoft.Exchange.WebServices.Auth
    participant Exchange as Exchange Web Services

    Client->>PamsEmail: Request email operation
    PamsEmail->>EwsAuth: Acquire authentication context
    EwsAuth->>Exchange: Authenticate request
    Exchange-->>EwsAuth: Authentication result
    EwsAuth-->>PamsEmail: Authenticated service access
    PamsEmail->>Exchange: Read or send mailbox data
    Exchange-->>PamsEmail: Email operation result
    PamsEmail-->>Client: Return application response
```

## Usage

```ts
// The Microsoft.Exchange.WebServices.Auth package runs in the Pams.Email
// server-side project. Browser code calls an application endpoint instead.

async function getInboxMessages() {
  const response = await fetch("/api/email/inbox", {
    method: "GET",
    headers: {
      Accept: "application/json",
    },
  });

  if (!response.ok) {
    throw new Error("Unable to load inbox messages.");
  }

  return response.json();
}

const messages = await getInboxMessages();
console.log(messages);
```

## AI Coding Instructions

- Keep `Microsoft.Exchange.WebServices.Auth` usage inside the `Pams.Email` server-side project; do not import it into browser code.
- Authenticate before creating or sending Exchange Web Services requests.
- Route client email actions through application APIs that call `Pams.Email`.
- Handle authentication failures separately from mailbox operation failures so callers receive actionable error responses.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (1)

- `Pams.Email` — `Pams/Logic/Pams.Email/Pams.Email.csproj`:1
