0
votes

I'm using the 1.3 requirement set for setting/getting the body value of an appointment/meeting: Office.context.mailbox.item.body.getAsync(...) and Office.context.mailbox.item.body.setAsync(...)

This works just fine literally everywhere and for all account types(Exchange on-premise and Outlook/Office365 accounts) except Outlook 2016 for MAC, where it fails to apply the html/text value of the body.

Checking the requirement sets (https://dev.office.com/reference/add-ins/outlook/tutorial-api-requirement-sets) MAC Outlook is listed as supporting all the requirement set versions(1.1 to 1.5) so it should support also the getAsync and setAsync methods for body property.

Any idea why it does not work?

UPDATE:

For setting value:

  function applyBody() {
    const $dBod = $.Deferred();
    try {
      Office.context.mailbox.item.body.setAsync(_appointmentInfo.body.value, { coercionType: _appointmentInfo.body.type }, function (asyncResult) {
        if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
          $dBod.resolve();
        }
        else {
          $dBod.reject(translate.getTranslation('ERROR_SETTING_BODY'));
        }
      });
    }
    catch (e) {
      $dBod.reject(e);
    }
    return $dBod.promise();
  }

For getting value:

  function getBody() {
    const $dBod = $.Deferred();
    getBodyType()
      .done(function (bodyType) {
        try {
          Office.context.mailbox.item.body.getAsync(bodyType, function (asyncResult) {
            if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
              $dBod.resolve({ value: asyncResult.value, type: bodyType });
            }
            else {
              $dBod.reject(translate.getTranslation('ERROR_GETTING_BODY_VALUE'));
            }
          });
        }
        catch (e) {
          $dBod.reject(e);
        }
      })
      .fail($dBod.reject);

    return $dBod.promise();
  }

For getting body type:

  function getBodyType() {
    const $dBod = $.Deferred();
    try {
      Office.context.mailbox.item.body.getTypeAsync(function (asyncResult) {
        if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
          $dBod.resolve(asyncResult.value);
        }
        else {
          $dBod.reject(translate.getTranslation('ERROR_GETTING_BODY_TYPE'));
        }
      });
    }
    catch (e) {
      $dBod.reject(e);
    }
    return $dBod.promise();
  }

UPDATE2:

Method I use for concatenating initial body value with my html:

const filterNullsAndUndefined = function (array, char) {
    return array.filter(function (val) { return val; }).join(char);
  };

I call it like this filterNullsAndUndefined([intialBodyValue, myHtml],'');

Where in my case the initialBodyValue is the value I get using body.getAsync(...) before appending myHtml to it( in order to preserve any text the user inserted before myHtml template gets appended). If I set myHtml directly on the body (overwrite) it works.

UPDATE 3:

Below the result we got when we appended the word 'Christmass':

appointment body as text

1
Which build version are you using?Mac_Outlook_Extensibility
Version 15.41 (build 171205). Checking for update says no new update.horymury
Could you post a code snippet of how you're using them? The APIs seem to work fine on our build.Mac_Outlook_Extensibility
updated the post with code snippets.horymury
update: did a very simple test: injected html : '<b>this is a bold test</b>' using the above and it does work. So it must be the much more complex html which I try to inject which does not work. However, in the case when it fails to inject the async result still says 'Succeded' which is very confusing. Is there a way I send you the exact html in private to help pinpoint the problem as it contains confidential information? Thank you.horymury

1 Answers

0
votes

We are able to reproduce the issue. Adding a <b>Text</b> after the </html> works on Outlook 2016 desktop, but not on the Mac. We will be fixing this soon.