@pnp/graph/outlook¶
Represents the Outlook services available to a user. Currently, only interacting with categories is supported.
You can learn more by reading the Official Microsoft Graph Documentation.
IUsers, IUser, IPeople¶
Scenario | Import Statement |
---|---|
Selective 1 | import { graph } from "@pnp/graph"; import {Outlook, IOutlook, MasterCategories, IMasterCategories, OutlookCategory, IOutlookCategory} from "@pnp/graph/outlook"; |
Selective 2 | import { graph } from "@pnp/graph"; import "@pnp/graph/outlook"; |
Preset: All | import { graph, Outlook, IOutlook, MasterCategories, IMasterCategories } from "@pnp/graph/presets/all"; |
Get All Categories User¶
import { graph } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/outlook";
// Delegated permissions
const categories = await graph.me.outlook.masterCategories();
// Application permissions
const categories = await graph.users.getById('{user id}').outlook.masterCategories();
Add Category User¶
import { graph } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/outlook";
// Delegated permissions
await graph.me.outlook.masterCategories.add({
displayName: 'Newsletters',
color: 'preset2'
});
// Application permissions
await graph.users.getById('{user id}').outlook.masterCategories.add({
displayName: 'Newsletters',
color: 'preset2'
});
Update Category¶
Testing has shown that displayName
cannot be updated.
import { graph } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/outlook";
import { OutlookCategory } from "@microsoft/microsoft-graph-types";
const categoryUpdate: OutlookCategory = {
color: "preset5"
}
// Delegated permissions
const categories = await graph.me.outlook.masterCategories.getById('{category id}').update(categoryUpdate);
// Application permissions
const categories = await graph.users.getById('{user id}').outlook.masterCategories.getById('{category id}').update(categoryUpdate);
Delete Category¶
import { graph } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/outlook";
// Delegated permissions
const categories = await graph.me.outlook.masterCategories.getById('{category id}').delete();
// Application permissions
const categories = await graph.users.getById('{user id}').outlook.masterCategories.getById('{category id}').delete();