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)

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:

filter: "from/emailAddress/address eq '[email protected]'"

By date:

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

With attachments:

filter: "hasAttachments eq true"

Unread only:

filter: "isRead eq false"

Last updated

Was this helpful?