//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 6 hours ago
//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 6 hours ago