Edits history of script submission #23341 for ' List Attachments (ms_outlook)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Attachments
     * List a message's attachments (id, name, content type, size) without their content. Requires Mail.Read (covered by the default Mail.ReadWrite).
     */
    export async function main(
      auth: RT.MsOutlook,
      message_id: string,
      mailbox: string | undefined
    ) {
      const base = `https://graph.microsoft.com/v1.0/${
        mailbox != null && mailbox !== ""
          ? `users/${encodeURIComponent(mailbox)}`
          : "me"
      }`
      const url = new URL(
        `${base}/messages/${encodeURIComponent(message_id)}/attachments`
      )
      url.searchParams.append(
        "$select",
        "id,name,contentType,size,isInline,lastModifiedDateTime"
      )
    
      const response = await fetch(url, {
        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 2 hours ago

  • bunnative
    //native
    
    /**
     * List Attachments
     * List a message's attachments (id, name, content type, size) without their content. Requires Mail.Read (covered by the default Mail.ReadWrite).
     */
    export async function main(
      auth: RT.Outlook,
      message_id: string,
      mailbox: string | undefined
    ) {
      const base = `https://graph.microsoft.com/v1.0/${
        mailbox != null && mailbox !== ""
          ? `users/${encodeURIComponent(mailbox)}`
          : "me"
      }`
      const url = new URL(
        `${base}/messages/${encodeURIComponent(message_id)}/attachments`
      )
      url.searchParams.append(
        "$select",
        "id,name,contentType,size,isInline,lastModifiedDateTime"
      )
    
      const response = await fetch(url, {
        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 11 hours ago

  • bunnative
    //native
    
    /**
     * List Attachments
     * List a message's attachments (id, name, content type, size) without their content. Requires Mail.Read on the connection.
     */
    export async function main(
      auth: RT.Outlook,
      message_id: string,
      mailbox: string | undefined
    ) {
      const base = `https://graph.microsoft.com/v1.0/${
        mailbox != null && mailbox !== ""
          ? `users/${encodeURIComponent(mailbox)}`
          : "me"
      }`
      const url = new URL(
        `${base}/messages/${encodeURIComponent(message_id)}/attachments`
      )
      url.searchParams.append(
        "$select",
        "id,name,contentType,size,isInline,lastModifiedDateTime"
      )
    
      const response = await fetch(url, {
        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 11 hours ago