//native
/**
* Create Draft Reply
* Create a draft reply (or reply-all) to a message without sending it. Returns the draft; send it with Send Draft. Requires Mail.ReadWrite (a connection default).
*/
export async function main(
auth: RT.Outlook,
message_id: string,
comment: string | undefined,
reply_all: boolean = false,
mailbox: string | undefined
) {
const base = `https://graph.microsoft.com/v1.0/${
mailbox != null && mailbox !== ""
? `users/${encodeURIComponent(mailbox)}`
: "me"
}`
const response = await fetch(
`${base}/messages/${encodeURIComponent(message_id)}/${
reply_all ? "createReplyAll" : "createReply"
}`,
{
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(
comment != null && comment !== "" ? { comment } : {}
),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 6 hours ago
//native
/**
* Create Draft Reply
* Create a draft reply (or reply-all) to a message without sending it. Returns the draft; send it with Send Draft. Requires Mail.ReadWrite on the connection.
*/
export async function main(
auth: RT.Outlook,
message_id: string,
comment: string | undefined,
reply_all: boolean = false,
mailbox: string | undefined
) {
const base = `https://graph.microsoft.com/v1.0/${
mailbox != null && mailbox !== ""
? `users/${encodeURIComponent(mailbox)}`
: "me"
}`
const response = await fetch(
`${base}/messages/${encodeURIComponent(message_id)}/${
reply_all ? "createReplyAll" : "createReply"
}`,
{
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(
comment != null && comment !== "" ? { comment } : {}
),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 6 hours ago