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 as an email in plain text format, body.getAsync() returns an incorrect value. #3988

Closed
t-miyake opened this issue Jan 10, 2024 · 11 comments
Assignees
Labels
Area: Outlook Issue related to Outlook add-ins

Comments

@t-miyake
Copy link

Provide required information needed to triage your issue

In Outlook on the web or New Outlook for Windows, when replying as an email in plain text format, body.getAsync() returns an incorrect value.
Specifically, the quoted part of the email is duplicated.

This issue does not occur when replying in HTML format or when using body.getAsync() with received emails.

Additionally, the same problem occurs regardless of whether Office.CoercionType.Html or Office.CoercionType.Text is specified as the argument when using body.getAsync().

Your Environment

  • Platform [PC desktop, Mac, iOS, Office on the web]: Office on the web or New Outlook for Windows
  • Host [Excel, Word, PowerPoint, etc.]: Outlook on the web or New Outlook for Windows

Expected behavior

Appropriately get the value of the mail body.

Current behavior

The quoted part (Original Message) of the email body is duplicated.

Steps to reproduce

  1. Open a received email and press the reply button.
  2. Change the format of the email to Plain Text. Alternatively, set the default Compose format to Plain Text in the settings of Outlook, and then press the reply button on an email that is in Plain Text format.
  3. Execute body.getAsync. Whether the email is edited or not seems to be irrelevant to this issue.

Link to live example(s)

I have created a simple sample.
The URL for the manifest file is as follows: https://outlook.addin.app/getbody/OutlookGetBody.xml

Manifest

<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp
  xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
  xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
  xsi:type="MailApp">
  <Id>734D9496-3F0F-406E-AFB6-93033D13EA14</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>T.Miyake</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="GetBody" />
  <Description DefaultValue="GetBody" />
  <IconUrl DefaultValue="https://outlook.addin.app/getbody/images/Icon64.png" />
  <SupportUrl DefaultValue="https://www.noraneko.co.jp/" />
  <AppDomains>
    <AppDomain>https://outlook.addin.app</AppDomain>
  </AppDomains>
  <Hosts>
    <Host Name="Mailbox" />
  </Hosts>
  <Requirements>
    <Sets>
      <Set Name="Mailbox" MinVersion="1.1" />
    </Sets>
  </Requirements>
  <FormSettings>
    <Form xsi:type="ItemRead">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://outlook.addin.app/getbody/" />
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
  </FormSettings>
  <Permissions>ReadWriteMailbox</Permissions>
  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
  </Rule>
  <DisableEntityHighlighting>false</DisableEntityHighlighting>
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides"
    xsi:type="VersionOverridesV1_0">
    <Requirements>
      <bt:Sets DefaultMinVersion="1.3">
        <bt:Set Name="Mailbox" />
      </bt:Sets>
    </Requirements>
    <Hosts>
      <Host xsi:type="MailHost">
        <DesktopFormFactor>
          <ExtensionPoint xsi:type="MessageReadCommandSurface">
            <OfficeTab id="TabDefault">
              <Group id="group1">
                <Label resid="groupLabel" />
                <Control xsi:type="Button" id="msgReadOpenPaneButton">
                  <Label resid="taskpaneButtonLabel" />
                  <Supertip>
                    <Title resid="taskpaneButtonLabel" />
                    <Description resid="taskpaneButtonTooltip" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="icon16" />
                    <bt:Image size="32" resid="icon32" />
                    <bt:Image size="64" resid="icon64" />
                    <bt:Image size="80" resid="icon80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="taskpaneUrl" />
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
          <ExtensionPoint xsi:type="MessageComposeCommandSurface">
            <OfficeTab id="TabDefault">
              <Group id="group2">
                <Label resid="groupLabel" />
                <Control xsi:type="Button" id="msgComposeOpenPaneButton">
                  <Label resid="taskpaneButtonLabel" />
                  <Supertip>
                    <Title resid="taskpaneButtonLabel" />
                    <Description resid="taskpaneButtonTooltip" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="icon16" />
                    <bt:Image size="32" resid="icon32" />
                    <bt:Image size="64" resid="icon64" />
                    <bt:Image size="80" resid="icon80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="taskpaneUrl" />
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>
    <Resources>
      <bt:Images>
        <bt:Image id="icon16" DefaultValue="https://outlook.addin.app/getbody/images/Icon16.png" />
        <bt:Image id="icon32" DefaultValue="https://outlook.addin.app/getbody/images/Icon32.png" />
        <bt:Image id="icon64" DefaultValue="https://outlook.addin.app/getbody/images/Icon64.png" />
        <bt:Image id="icon80" DefaultValue="https://outlook.addin.app/getbody/images/Icon80.png" />
      </bt:Images>
      <bt:Urls>
        <bt:Url id="taskpaneUrl" DefaultValue="https://outlook.addin.app/getbody/taskpane.html" />
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="groupLabel" DefaultValue="GetBody" />
        <bt:String id="taskpaneButtonLabel" DefaultValue="GetBody" />
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="taskpaneButtonTooltip" DefaultValue="GetBody" />
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>

JavaScript

Office.onReady().then(() => {
    Office.context.mailbox.item.body.getAsync(Office.CoercionType.Html, (result) => {
            document.getElementById("htmlBody").innerHTML = escapeHtml(result.value);
    });
    Office.context.mailbox.item.body.getAsync(Office.CoercionType.Text, (result) => {
            document.getElementById("textBody").innerHTML = escapeHtml(result.value);
    });
});

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

HTML

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
</head>
<body>
    <p>--HTML Body--</p>
    <p id="htmlBody"></p>
    <br><br>
    <p>--Text Body--</p>
    <p id="textBody"></p>
    <script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>
    <script src="taskpane.js"></script>
</body>
</html>

Context

I am facing challenges due to this issue, as it leads to providing users with incorrect information about the email body.

Useful logs

This is the result of running the above sample. It might be a bit hard to understand, but please check the issue.

Replying to a text format email in text format ※Issue present
Text-Text

Replying to an HTML format email in text format ※Issue present
Html-Text

Replying to a text format email in HTML format ※No issue
Text-Html

Replying to an HTML format email in HTML format ※No issue
Html-Html

Reading text format emails ※No issue
Read-Text

Reading HTML format emails ※No issue
Read-HTML

Outlook for Windows (Traditional ) ※No issue
Windows

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label Jan 10, 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 Jan 10, 2024
@exextoc exextoc self-assigned this Jan 10, 2024
@bchenhs
Copy link

bchenhs commented Jan 10, 2024

We also observed this issue and it is impacting over 100k of our add-in users. @exextoc we would much appreciate an update and eta on a fix so we can communicate to our impacted users. Thank you!

@t-miyake
Copy link
Author

@exextoc Could you please provide an update on the status of this issue? Given the significant impact of the problem, I am hoping for a fix. We also have over 150k users affected by this. Thanks!

@ajays-msft
Copy link

We are actively investigating this and will get back soon.

@ajays-msft
Copy link

@t-miyake The issue has been resolved at the server side. Can you please check in couple of hours and reply back?

@t-miyake
Copy link
Author

@ajays-msft Thank you. I have confirmed that the issue I reported has been completely fixed. However, a new issue has arisen.
It appears that when replying to an email in HTML format, the quoted part cannot be got using body.getAsync().

Here are the results of my tests:

Replying to a text format email in text format ※Issue is Fixed.
TEXT2TEXT

Replying to an HTML format email in text format ※Issue is Fixed.
HTML2TEXT

Replying to a text format email in HTML format ※New issue.
TEXT2HTML

Replying to an HTML format email in HTML format ※New issue.
HTML2HTML

@ajays-msft
Copy link

The new issue you mentioned is a known bug for long. A fix to that issue has caused a regression and we reverted it. You can track the fix for the HTML issue in this github post. #2317

@t-miyake
Copy link
Author

@ajays-msft Thank you very much. I understand.
This Issue has been Fixed so I will be closed.

@bchenhs
Copy link

bchenhs commented Jan 16, 2024

Hi @ajays-msft, thanks for the update on the fix.

@exextoc exextoc removed the Needs: attention 👋 Waiting on Microsoft to provide feedback label Jan 18, 2024
@bchenhs
Copy link

bchenhs commented Apr 12, 2024

Hi @exextoc @ajays-msft We just started seeing this issue again. Did another update rollout that re-introduced this bug?

@neprasad-microsoft
Copy link

The fix for this issue caused another issue (#4392 ) . So, we are reverting this and are working on this issue. Unfortunately, we do not have any timelines for this right now.

@neprasad-microsoft neprasad-microsoft added the Needs: attention 👋 Waiting on Microsoft to provide feedback label Apr 29, 2024
@ajays-msft
Copy link

This issue is fixed now.

@exextoc exextoc removed the Needs: attention 👋 Waiting on Microsoft to provide feedback label May 17, 2024
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
Projects
None yet
Development

No branches or pull requests

5 participants