Outlook add-in displayNewMessageForm is not adding attachments

206 Views Asked by At

I have an Outlook add-in which is using the office.js API for a Taskpane application. I am trying to allow the user to send a new email with an attachment, where the attachment is the email that they are currently viewing. I can create a new window and populate the main properties (to, subject, body, etc...), however, when I use the code below, the attachments are not added to the new email. It looks like I need to use an "item" attachment and give it the "itemId" of the current message, but I have also tried using a "file" attachment with various working URLs. Both attachment types fail to add any attachment, and no errors are shown in the browser debug console. I am using the following code, which I have found in the documentation and other SO questions, but does not seem to work in web browsers or Outlook for Mac:

Office.context.mailbox.displayNewMessageForm({
    toRecipients: ["[email protected]"],
    subject: "Test Subject",
    htmlBody: 'Test Body ',
    attachments :
          [
              { type: "item", itemId : Office.context.mailbox.item.itemId, name: "test_email.msg" }
          ],
          options : { asyncContext: null },
          callback : function (asyncResult)
          {
              if (asyncResult.status == "failed")
              {
                  showMessage("Action failed with error: " + asyncResult.error.message);
              }
          }
});

The window that opens is shown below. It has populated the main properties but does not have the attachment.

Any ideas on what I may be doing incorrectly?

enter image description here

0

There are 0 best solutions below