@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¶
Get All Categories User¶
import { graphfi } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/outlook";
const graph = graphfi(...);
// 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 { graphfi } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/outlook";
const graph = graphfi(...);
// 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 { graphfi } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/outlook";
import { OutlookCategory } from "@microsoft/microsoft-graph-types";
const graph = graphfi(...);
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 { graphfi } from "@pnp/graph";
import "@pnp/graph/users";
import "@pnp/graph/outlook";
const graph = graphfi(...);
// 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();