Edits history of script submission #23338 for ' Get Folder (outlook)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get Folder
     * Get a mail folder by id or well-known name (`inbox`, `drafts`, `sentitems`, `deleteditems`, `archive`, `junkemail`), with its unread and total counts. Requires Mail.Read (covered by the default Mail.ReadWrite) (a shared mailbox needs Mail.Read.Shared, not a default).
     */
    export async function main(
      auth: RT.Outlook,
      folder: string,
      mailbox: string | undefined
    ) {
      const base = `https://graph.microsoft.com/v1.0/${
        mailbox != null && mailbox !== ""
          ? `users/${encodeURIComponent(mailbox)}`
          : "me"
      }`
      const response = await fetch(
        `${base}/mailFolders/${encodeURIComponent(folder)}`,
        {
          headers: {
            Authorization: `Bearer ${auth.token}`,
            Accept: "application/json",
          },
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago

  • bunnative
    //native
    
    /**
     * Get Folder
     * Get a mail folder by id or well-known name (`inbox`, `drafts`, `sentitems`, `deleteditems`, `archive`, `junkemail`), with its unread and total counts. Requires Mail.Read on the connection (Mail.Read.Shared for a shared mailbox).
     */
    export async function main(
      auth: RT.Outlook,
      folder: string,
      mailbox: string | undefined
    ) {
      const base = `https://graph.microsoft.com/v1.0/${
        mailbox != null && mailbox !== ""
          ? `users/${encodeURIComponent(mailbox)}`
          : "me"
      }`
      const response = await fetch(
        `${base}/mailFolders/${encodeURIComponent(folder)}`,
        {
          headers: {
            Authorization: `Bearer ${auth.token}`,
            Accept: "application/json",
          },
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago