# Create Outlook Email Feed

## User Intent

"How do I sync Outlook/Microsoft 365 email? Show me Outlook email feed configuration."

## Operation

**SDK Method**: `createFeed()` with FeedTypes.Email\
**Auth**: Microsoft OAuth tokens

***

## Code Example (TypeScript)

```typescript
import { Graphlit } from 'graphlit-client';
import { FeedTypes, FeedServiceTypes, EmailListingTypes } from 'graphlit-client/dist/generated/graphql-types';

const graphlit = new Graphlit();

const feed = await graphlit.createFeed({
  name: 'Outlook Inbox',
  type: FeedTypes.Email,
  email: {
    type: FeedServiceTypes.MicrosoftEmail,
    microsoft: {
      type: EmailListingTypes.Past,
      clientId: process.env.MICROSOFT_CLIENT_ID!,
      clientSecret: process.env.MICROSOFT_CLIENT_SECRET!,
      refreshToken: process.env.MICROSOFT_REFRESH_TOKEN!,
      readLimit: 100,
      inboxOnly: true,
      excludeSentItems: true
    },
    includeAttachments: true,
  },
  // Optional: add workflow for content processing
  // workflow: { id: workflow.createWorkflow.id }
});

console.log(`Created Outlook feed: ${feed.createFeed.id}`);
```

***

## Configuration

**type**: `EmailListingTypes.Past` or `EmailListingTypes.New`\
**readLimit**: Number of emails to sync\
**inboxOnly**: Only sync inbox folder\
**excludeSentItems**: Exclude sent messages\
**includeSpam**: Include junk folder (default: false)\
**includeDeletedItems**: Include deleted items (default: false)\
**includeAttachments**: Download email attachments\
**filter**: OData filter query

***

## Microsoft OAuth Setup

1. Register app in Azure Portal
2. Add Microsoft Graph API permissions (`Mail.Read`)
3. Create client secret
4. Configure redirect URI
5. Get refresh token via OAuth flow

***

## What Gets Synced

* Email subject, body, and headers
* Sender and recipient information
* Timestamps and folder names
* Attachments (if enabled)
* Conversation threads

***

## Filtering Examples

**By sender**:

```typescript
filter: "from/emailAddress/address eq 'user@example.com'"
```

**By date**:

```typescript
filter: "receivedDateTime ge 2024-01-01T00:00:00Z"
```

**With attachments**:

```typescript
filter: "hasAttachments eq true"
```

**Unread only**:

```typescript
filter: "isRead eq false"
```

***

## Related

* [Gmail Feed](/api-guides/use-cases/feeds/messaging/feed-create-gmail.md) - Google email
* [Outlook Calendar Feed](/api-guides/use-cases/feeds/calendars/feed-create-outlook-calendar.md) - Microsoft calendar
* [Microsoft Teams Feed](/api-guides/use-cases/feeds/messaging/feed-create-microsoft-teams.md) - Teams messaging


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.graphlit.dev/api-guides/use-cases/feeds/messaging/feed-create-outlook-email.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
