Carbo
Carbo

Reputation: 329

Outlook add-in body setasync UI updates but result is blank

I made a test office.js Outlook add-in that injects formatted HTML into the Office.context.mailitem.body with setasync and coercion type of HTML. Everything worked but suddenly mid-January a problem appeared with editing calendar invites. The UI gets updated but when the invite is sent the text gets removed. When the calendar invite is opened from the calendar, the text is blank. Some observations:

  1. Editing the body of emails still works. The problem only occurs with calendar invites.
  2. If you manually add text after the add-in has inserted its HTML, the invite works. If you add text first and then the add-in adds its HTML but you do nothing else, the invite text is just the original text - no HTML. It is acting like the setasync updates the UI but some sort of internal dirty flag does not get set and the text gets blanked out.
  3. This only occurs in Outlook 2013. The same email account on Outlook 2016 works.
  4. This occurs on our work email which I think has an Office Online backend, but not on my azure test tenant.
  5. The issue does not occur with text only invites with coercion type set to text.
  6. It does not matter how simple the inserted HTML is. Inserting just the following simple HTML results in the issue:

    <b>this is bold text</b>
    

Any ideas what could be happening?

Thanks in advance.

Upvotes: 2

Views: 473

Answers (1)

Tim Wan
Tim Wan

Reputation: 155

So this is indeed a bug that will need to be fixed. In the meantime, I was playing around with this, and as a workaround, I found that if you dirty the body after you do a SetBody then the message will send correctly.

You can either do this manually by just typing a space, or in the actual call, for example:

Office.context.mailbox.item.body.setAsync
(
    "<B>tim test</b>",
    {
        "coercionType" : "html"
    },
    function (asyncResult)
    {
        Office.context.mailbox.item.body.prependAsync(".");
    }
);

(you may want to insert something less intrusive, like a space)

Upvotes: 1

Related Questions