spacer
Skip to content

Graph Mailbox

More information can be found in the official Graph documentation:

IMailboxSettings

Invokable Banner Selective Imports Banner

Get User's Mailbox Setting

import { graphfi } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/mail/mailbox";

const graph = graphfi(...);

const currentUser = graph.me;
const mailboxSettings = await currentUser.mailboxSettings();
const automaticRepliesSetting = await currentUser.mailboxSettings.automaticRepliesSetting();
const dateFormat = await currentUser.mailboxSettings.dateFormat();
const language = await currentUser.mailboxSettings.language();
const timeFormat = await currentUser.mailboxSettings.timeFormat();
const timeZone = await currentUser.mailboxSettings.timeZone();
const workingHours = await currentUser.mailboxSettings.workingHours();
const userPurpose = await currentUser.mailboxSettings.userPurpose();

Get User's Focused Inbox Overrides

import { graphfi } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/mail/mailbox";

const graph = graphfi(...);

const currentUser = graph.me;
const fio = await currentUser.focusedInboxOverrides();

Get User's Focused Inbox Override by Id

import { graphfi } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/mail/mailbox";

const graph = graphfi(...);

const currentUser = graph.me;
const fio = await currentUser.focusedInboxOverrides.getById({fio id});

Add Focused Inbox Override

import { graphfi } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/mail/mailbox";

const graph = graphfi(...);

const override: InferenceClassificationOverride = {
        classifyAs: "focused",
        senderEmailAddress: {
            name: "Mary Smith",
            address: "msmith@contoso.com",
        },
    };

const currentUser = graph.me;
const fio = await currentUser.focusedInboxOverrides.add(override);

Update Focused Inbox Override

import { graphfi } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/mail/mailbox";

const graph = graphfi(...);

const currentUser = graph.me;
const fio = await currentUser.focusedInboxOverrides.update({ senderEmailAddress: { name: "marysmith@contoso.com" }});

Delete Focused Inbox Override

import { graphfi } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/mail/mailbox";

const graph = graphfi(...);

const currentUser = graph.me;
const fio = await currentUser.focusedInboxOverrides.getById({fio id}).delete();