OfficeDev / office-js

A repository for issues related to the Office JavaScript APIs and Office Add-ins platform. Find the Office.js library in Office.js CDN: https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
724 stars 106 forks source link

Issue: getAsync Returns <span> Instead of <div> When Retrieving Long Email Body in Outlook Add-in (Modern Browsers) #5501

Closed harshitgoyal1711 closed 3 weeks ago

harshitgoyal1711 commented 1 month ago

Description: We are encountering an intermittent issue with Office.context.mailbox.item.body.getAsync when retrieving email body content after composing a new email with a long text input (e.g., 99,999 characters). Instead of maintaining the original <div> structure, the content is sometimes unexpectedly wrapped inside a <span> element. However, in some cases, it works fine and retains the expected <div> structure.

Steps to Reproduce:

  1. Compose a new email manually in Outlook.
  2. Add long text (99,999 characters) in the email body, ensuring it is formatted inside <div> elements.
  3. Call getAsync to retrieve the email body:

Office.context.mailbox.item.body.getAsync(Office.CoercionType.Html, (result) => { console.log(result.value); });

Actual Output (In Modern Browsers) (Mostly Happens):

<span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem... </span>

Expected Output (Sometimes Works Fine as Expected):

The original <div> structure should be retained:

<div style="color: black;"> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor...</p> </div>

Environment Details: Browser: Chrome, Edge, Safari (Modern Browsers) Platform: Outlook Web Add-in

Observations: This issue only occurs in browsers and not in desktop Outlook. The <div> structure is maintained for smaller email bodies. For very long email content (99,999 characters), <div> elements are sometimes replaced with <span>, but other times they are retained correctly.

Request for Support:

Looking forward to your response.

arpitsangwanmsft commented 1 month ago

Hey @harshitgoyal1711! It is not expected for the Html structure to be the same when body is retrieved. Please refer to the public docs for body.getAsync for more context. For reference: Image

microsoft-github-policy-service[bot] commented 4 weeks ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

microsoft-github-policy-service[bot] commented 3 weeks ago

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.