0

I am developing an Outlook add-in using Office.js for an Exchange On-Premises server. Due to the limitations of Exchange On-Prem, the supported Office.js version is 1.5 or lower. Unfortunately, in Office.js v1.5, there is no built-in API to delete attachments from an email.

I explored the option of using Exchange Web Services (EWS) and found that the DeleteAttachment API works as expected when tested via SOAP UI. However, when attempting to call this API from the Outlook add-in using makeEWSRequestAsync, I discovered that Outlook only permits a restricted set of EWS operations. The DeleteAttachment API is not included in the allowed set of EWS operations that can be called via makeEWSRequestAsync.

Given these constraints, is there any way to delete an attachment from an email in an Exchange On-Premises environment via Office.js or any other workaround?

Would appreciate any guidance or alternative approaches to achieve this functionality.

1 Answer 1

0

You should be able to use MessageCompose.removeAttachmentAsync.

Here's a small code sample:

Office.context.mailbox.item.removeAttachmentAsync(
  (attachmentId,
  (result) => {
    if (result.status === Office.AsyncResultStatus.Failed) {
      console.error(result.error.message);
      return;
    }

    console.log(`Attachment removed successfully.`);
  }
);

There's more information in the article Manage an item's attachments in a compose form in Outlook. Hope that helps!

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your response. Since I'm developing an Exchange On-Prem add-in, I’m limited to Office.js ≤ 1.5 or EWS APIs. As removeAttachmentAsync is only available in Office.js 1.8, it doesn’t work in OWA. I tried calling DeleteAttachment via fetch(), but the browser sends a preflight OPTIONS request, which gets a 401 Unauthorized response, causing a CORS error. Any suggestions on how to resolve this?
I'm confused. removeAttachmentAsync is listed as "API set: Mailbox 1.1" in the linked documentation. Is that not accurate?
Yes, I have tried the removeAttachmentAsync code. I've observed that it is able to remove the attachments from the mac client, but when same method is used in OWA, it is not working. That's why I'm trying to hit the EWS url via fetch, but in that also I'm stuck as it is giving 401 unauthorized in the preflight request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.