Edits history of script submission #23331 for ' Create Draft Reply (ms_outlook)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //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.MsOutlook,
      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 2 hours ago

  • bunnative
    //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 11 hours ago

  • bunnative
    //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 11 hours ago