Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When replying or forwarding an email body.getAsync() returns an incorrect value #4392

Closed
bchenhs opened this issue Apr 23, 2024 · 7 comments
Closed
Assignees
Labels
Area: Outlook Issue related to Outlook add-ins Status: under investigation Issue is being investigated

Comments

@bchenhs
Copy link

bchenhs commented Apr 23, 2024

Provide required information needed to triage your issue

Similar symptoms as:
#3988
#4360

  • For reply/forward emails, the item.body.getAsync returns mismatched and duplicated contents after item.body.setAsync

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]: Office on the web, the New Outlook for Windows
  • Host [Excel, Word, PowerPoint, etc.]: Outlook
  • Office version number:
  • Operating System: MacOS 14.4.1
  • Browser (if using Office on the web): Chrome

Expected behavior

Appropriately get the value of the mail body for reply/forward emails.

Current behavior

The mail body is incorrect and contains duplicating contents after item.body.setAsync.

Steps to reproduce

  1. Open a received email and press the reply button. We see this issue on the Microsoft Viva emails.
  2. Execute item.body.getAsync, and sets the same content back with item.body.setAsync
  3. Execute body.getAsync.

Link to live example(s)

These are taken from #3988

Javascript

$("#run").on("click", run);

const timeout = 1000;

function run() {
  // Gets current email body
  Office.context.mailbox.item.body.getAsync(Office.CoercionType.Html, (result) => {
    document.getElementById("firstBody").innerHTML = escapeHtml(result.value);

    setTimeout(() => {
      // Sets the same email body
      Office.context.mailbox.item.body.setAsync(result.value, { coercionType: Office.CoercionType.Html }, (result) => {
        Office.context.mailbox.item.body.getAsync(Office.CoercionType.Html, (result) => {
          // Gets email body again after setAsync
          document.getElementById("secondBody").innerHTML = escapeHtml(result.value);
        });
      });
    }, timeout);
  });
}

function escapeHtml(html) {
  return html
    .replace(/&/g, "&")
    .replace(/</g, "&lt;")
    .replace(/>/g, "&gt;")
    .replace(/"/g, "&quot;")
    .replace(/'/g, "&#039;");
}

HTML

<div>
	<button id="run" class="ms-Button">
    <span class="ms-Button-label">Run</span>
</button>

	<p>--FIRST--</p>
	<p id="firstBody"></p>
	<br><br>
	<p>--SECOND--</p>
	<p id="secondBody"></p>
</div>

Provide additional details

  • On the first getAsync, the body contains elementToProof which doesn't exist on subsequent getAsync results.
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label Apr 23, 2024
@exextoc exextoc added Needs: attention 👋 Waiting on Microsoft to provide feedback Area: Outlook Issue related to Outlook add-ins and removed Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP labels Apr 23, 2024
@exextoc exextoc self-assigned this Apr 23, 2024
@anjalitp
Copy link
Collaborator

@bchenhs we are not able to repro the issue on our side. Could you please share a repro video of the issue?

@anjalitp anjalitp added Needs: author feedback Waiting for author (creator) of Issue to provide more info and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Apr 24, 2024
@bchenhs
Copy link
Author

bchenhs commented Apr 24, 2024

Hi @anjalitp I've updated the description and sample script to better demonstrate the issue. The missing step in the original description was calling body.setAsync.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: author feedback Waiting for author (creator) of Issue to provide more info labels Apr 24, 2024
@anjalitp
Copy link
Collaborator

Thanks for updating the issue. We are able to repro the issue with body.setAsync call. It seems like body.setAsync call is not replacing the quoted text in the original body, hence the subsequent getAsync call shows the quoted text twice.
This looks like expected behaviour for body.setAsync API on OWA but we would like to understand more about your Add-in use case which is being blocked by this issue. Could you please share the same?

@anjalitp anjalitp added Needs: author feedback Waiting for author (creator) of Issue to provide more info and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Apr 25, 2024
@bchenhs
Copy link
Author

bchenhs commented Apr 25, 2024

@anjalitp Can you please elaborate on how this looks like expected behaviour for body.setAsync when the API specifies it "Replaces the entire body with the specified text."?

The example on the API documentation site states:

Office.context.mailbox.item.body.setAsync(
    "<b>(replaces all body, including threads you are replying to that may be on the bottom)</b>",
    { coercionType: "html", asyncContext: "This is passed to the callback" },
    function callback(result) {
        // Process the result.
});

This is also a recent change in behaviour. Prior to a few day ago, it was working as expected and followed the API spec.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: author feedback Waiting for author (creator) of Issue to provide more info labels Apr 25, 2024
@hsptkt
Copy link

hsptkt commented Apr 25, 2024

Hi @anjalitp @exextoc, just to add to this report, the symptoms here fully match the other issues linked (#3988 and #4360), where the add-in team was able to confirm there was a regression. Tagging in @ajays-msft in case he can add context as well.

@anjalitp anjalitp added Status: under investigation Issue is being investigated and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Apr 29, 2024
@anjalitp
Copy link
Collaborator

@hsptkt @bchenhs Thanks for providing more context. We are invesigating this issue further and we will update this thread once we have an update.

Internal Tracking ID: 4530717

@ajays-msft
Copy link

In OWA, getBody or setBody reflects what can be possible in from the UI. For example, if the messages are grouped by conversation, reply/forward will show quoted text (... which requires user to expand to see the full message). When there is quoted text, get/set body will only get/set the editable content in the email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Outlook Issue related to Outlook add-ins Status: under investigation Issue is being investigated
Projects
None yet
Development

No branches or pull requests

5 participants