Skip to content

Classic outlook html body returns missing info #6438

@GirtsJermacans

Description

@GirtsJermacans

When calling a method Office.context.mailbox.item.body.getAsync with coercion type html. there are scenarios in which returned HTML is missing data for the inserted shapes that have some text in them. In particular affected seem to be textboxes that overlap each other but might not be uniquely related to just them.

Reason seem to be because returned html contains many different conditionals and in this example, often one of the conditionals does not contain all the data, but rather just partial. Conditional examples:

  • <!--[if gte vml 1]> <![endif]--> (for older browsers that support vml)
  • <![if !vml]> <![endif]> (for modern browsers)

The text part for shapes / textboxes usually can be found in alt attributes of img tags, however if you overlap textboxes, often these attributes are missing within <![if !vml]> <![endif]> conditional, but rather just contains id to a <v:shape> that is inside <!--[if gte vml 1]> <![endif]-->.

VML conditional comments <!--[if gte vml 1]>...<![endif]--> are not supported in modern browsers. Also attempting to parse HTML containing these conditionals using the DOM approach does not work. Which means cleaning of HTML is required in order to get all the data for textboxes, which can to data loss.

Your Environment

  • Platform: Classic Outlook on desktop
  • Host [Excel, Word, PowerPoint, etc.]: Outlook
  • Office version number: Office.context.diagnostics.version - 16.0.19530.20074
  • Operating System: Windows 11 Enterprise

Expected behavior

When user adds textboxes with text 'my textbox', then a method call Office.context.mailbox.item.body.getAsync of coercion type html should return html that has <![if !vml]> <![endif]> conditional with img tag, that has alt attribute on them with 'my textbox' as the value.

Current behavior

When user adds textboxes with text 'my textbox', then a method call Office.context.mailbox.item.body.getAsync of coercion type html returns html that has <![if !vml]> <![endif]> conditional with img tag, that is missing alt attribute and there is no 'my textbox' value available.

Steps to reproduce

  1. Compose new mail item and add 2 textboxes as below.
    Image
  2. Send mail item and observe what returns Office.context.mailbox.item.body.getAsync with coercion type html
  3. In most cases 'alt attribute will be missing within <![if !vml]> <![endif]> img tag but rather will have ids to the v:shapes.
    The body could look something like this:
<![if !vml]>
  <span style='mso-ignore:vglayout'>
      <table cellpadding=0 cellspacing=0 align=left>
          <tr>
              <td width=147 height=75></td>
          </tr>
          <tr>
              <td></td>
              <td><img width=419 height=285 src="cid:image001.png@01DC80C6.58692D00"
                      v:shapes="Text_x0020_Box_x0020_1 Text_x0020_Box_x0020_2"></td>
          </tr>
      </table>
  </span><![endif]>

While expected was something like following:

<![if !vml]>
  <span style='mso-ignore:vglayout'>
      <table cellpadding=0 cellspacing=0 align=left>
          <tr>
              <td width=147 height=75></td>
          </tr>
          <tr>
              <td></td>
              <td><img width=200 height=100 src="cid:image001.png@01DC80C6.58692D01" alt="Textbox1 text"
                      v:shapes="Text_x0020_Box_x0020_1"></td>
              <td><img width=200 height=100 src="cid:image001.png@01DC80C6.58692D02" alt="Textbox2 text"
                      v:shapes="Text_x0020_Box_x0020_2"></td>
          </tr>
      </table>
  </span><![endif]>

Context

We are analyzing text data provided in mail item for certain things. Since textboxes and shapes can have text data, it should also be analyzed. If this data is missing, this can allow mail items to be sent without being accurately analyzed.

Useful logs

function getMailbox() : Office.Mailbox {
	const result = Office.context.mailbox;
	if (result) {
		return result;
	}
	throw new Error();
}

function getMailboxItem() : MailboxItem {
	const result = getMailbox().item;
	if (result) {
		return result;
	}
	throw new Error();
}

getItemBodyAsync(): Promise<string> {
	return new Promise((resolve, reject) => {
		this.getMailboxItem().body.getAsync('html', (asyncResult) => {
			if (asyncResult.status === Office.AsyncResultStatus.Failed) {
				reject(asyncResult.error);
			} else {
				resolve(asyncResult.value);
			}
		});
	});
}

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions