0

List Categories

by
Published today

List the categories (labels) defined in the connected mailbox, with their colors. Requires MailboxSettings.Read, which is not a connection default: tick it when connecting.

Script outlook Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 5 hours ago
1
//native
2

3
/**
4
 * List Categories
5
 * List the categories (labels) defined in the connected mailbox, with their colors. Requires MailboxSettings.Read, which is not a connection default: tick it when connecting.
6
 */
7
export async function main(auth: RT.Outlook) {
8
  const response = await fetch(
9
    "https://graph.microsoft.com/v1.0/me/outlook/masterCategories",
10
    {
11
      headers: {
12
        Authorization: `Bearer ${auth.token}`,
13
        Accept: "application/json",
14
      },
15
    }
16
  )
17

18
  if (!response.ok) {
19
    throw new Error(`${response.status} ${await response.text()}`)
20
  }
21

22
  return await response.json()
23
}
24