//native
/**
* Get Message
* Get one message by id, with its body as HTML or plain text. 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.MsOutlook,
message_id: string,
select: string | undefined,
body_format: "html" | "text" = "html",
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)}`)
if (select != null && select !== "") {
url.searchParams.append("$select", select)
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
Prefer: `outlook.body-content-type="${body_format}"`,
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago
//native
/**
* Get Message
* Get one message by id, with its body as HTML or plain text. 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,
message_id: string,
select: string | undefined,
body_format: "html" | "text" = "html",
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)}`)
if (select != null && select !== "") {
url.searchParams.append("$select", select)
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
Prefer: `outlook.body-content-type="${body_format}"`,
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 11 hours ago
//native
/**
* Get Message
* Get one message by id, with its body as HTML or plain text. Requires Mail.Read on the connection (Mail.Read.Shared for a shared mailbox).
*/
export async function main(
auth: RT.Outlook,
message_id: string,
select: string | undefined,
body_format: "html" | "text" = "html",
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)}`)
if (select != null && select !== "") {
url.searchParams.append("$select", select)
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
Prefer: `outlook.body-content-type="${body_format}"`,
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 11 hours ago