OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
657 stars 93 forks source link

Outlook Add-in: Original message appended to body unexpectingly #1779

Closed cody-lettau closed 3 years ago

cody-lettau commented 3 years ago

Expected Behavior

When replying to a message, the original message is appended to the body (bottom) after any "on send" function has ran within our add-in. This occurs in the browser (Chrome - office.com). I would expect that whatever we set the body of the reply to within our "on-send" function, that would be what is sent (and nothing else is appended).

Current Behavior

When replying to a message (with conversation view enabled), you see the 3 little dots at the bottom (expanding this includes the original message being replied to). From within our add-in, if we call Office.context.mailbox.item.body.getAsync('html', ...), it does not include the content that is there when you press the three dots. Yet, when we send the message, it is always appended unless the user has pressed the 3 dots. In the case where the user has pressed the 3 dots to expand and show the original message, then it is part of the body html when we call Office.context.mailbox.item.body.getAsync('html', ...). In that case, we are able to either remove it or encrypt it if desired and it does not get appended again after our "on-send" function runs.

Steps to Reproduce, or Live Example

  1. Click to reply to a message.
  2. In an on-send function within an add-in, attempt to set the HTML of the body to desired content.
  3. Send the message.

Result: The message that was sent will include the original message under the reply, even though it was not part of the HTML that the body was set to.

Context

This significantly impacts how we can reply to a message. We are focused on sending encrypted messages and that entails controlling the html of the message. When the original message is being appended and we have no control over that, it leads to that portion of the email chain not being encrypted.

Your Environment

Browser (Chrome - office.com) Note: This does not appear to be an issue within the desktop client because when I click reply, the original message is shown and part of the HTML when calling Office.context.mailbox.item.body.getAsync('html', ...).

cody-lettau commented 3 years ago

Just to note, I did originally open https://stackoverflow.com/questions/66889440/outlook-add-in-how-to-remove-or-not-include-original-email-when-replying for this, but it seems more like a bug since it is handled differently across platforms.

exextoc commented 3 years ago

@cody-lettau This is by design in OWA. body.getAsync API will return the complete text only if '...' button is clicked.

cody-lettau commented 3 years ago

@exextoc thanks for the reply.

This seems quite limiting if an add-in is trying to do anything with the entire message being sent. Relying on the user to click the '...' in order for the add-in to function properly seems counterproductive.

Are you aware of any possible workarounds or have any recommendations of how we could go about obtaining the entire body (including what gets appended when '...' button is clicked)?

exextoc commented 3 years ago

One possible workaround is to get the body using makeEwsRequestAsync API. You can also use Graph APIs to get Message Body using itemId.Documentation on Graph API .

cody-lettau commented 3 years ago

@exextoc I'll give that a try! Thank you for the recommendation -- much appreciated!

cody-lettau commented 3 years ago

@exextoc this works to retrieve the entire body of the message, which is a necessary part of our solution.

That said, we still have an issue where the original message is always appended to the message after the processing of our "onSend" function. I have not found a way to stop OWA from appending the original message unless the "..." button at the bottom of the compose is clicked.

Is there anyway to somehow disable that appending of the original message or to programmatically click it from within our compose add-in? Without being able to stop this from appending the original message, it doesn't seem possible to actually have full control over the content of the message being sent.

exextoc commented 3 years ago

Currently the feature: Remove email body during on send, you requested, is not a part of the product. We track Outlook add-in feature requests on our Tech Community Page. Please submit your request there and choose the appropriate label(s). Feature requests on Tech Community are considered, when we go through our planning process.

Github Label: “Type: product feature request” aka.ms/M365dev-suggestions

[Outlook Add-ins Engineering Team]

cody-lettau commented 3 years ago

I appreciate the response, even though it is quite unfortunate that there is absolutely no way to control what is actually sent when replying to an email.

I opened this feature request: https://techcommunity.microsoft.com/t5/microsoft-365-developer-platform/ability-to-disable-appending-of-original-message-on-replies/idi-p/2306606#M37