2

I'm working on the outlook add-in. But I get the issue that sometimes Office.context.mailbox.item.body.getAsync will failed when the add-in page reloaded. The worst thing is that, once body.getAsync return the error "APICallFailedDueToItemChange", the body.getAsync will be always failed with the same error. The detail of this error is {name: "APICallFailedDueToItemChange", message: "The selected item has been changed.", code: 9030}

I tried to recall the getAsync and even reload the whole window to make the add-in restarted, but the error will happen persistently. The only way is switching to another email.

Reproduce steps: 1. Create any outlook add in which try to get the email body 2. after add-in loaded, reload the add-in window 3. Once the 9030 error happened, those code in console will always trigger the same error until I switch to another email

await new Promise((resolve, reject) => {
    window.Office.context.mailbox.item.body.getAsync('text', (result) => {
      if (result.status === 'succeeded') {
        console.log(result.value)
        return resolve(result.value); // updated as suggested by Mavi Domates
      } else {
        console.error(result.error)
        return reject(result.error);
      }
    })
  })

I expect the getAsync should work fine even the previous callback is failed, but actual the exception will never be cleaned.

Andrew
  • 21
  • 3
  • What client are you testing this on? Windows Win32 Desktop? Outlook Web Access? Etc. Also what specific version? – Outlook Add-ins Team - MSFT May 07 '19 at 20:44
  • Also how are you reloading the add-in window? – Outlook Add-ins Team - MSFT May 07 '19 at 20:48
  • If you are using the SupportsPinning feature. You also need to implement addHandlerAsync for the itemChanged event. Otherwise, calling APIs on the item will result in that error. – Outlook Add-ins Team - MSFT May 07 '19 at 20:51
  • @OutlookAdd-insTeam-MSFT My client is MacOS 10.14.4 outlook 16.24. For reproduce this window, I reloaded the page by right click the add-in and select the "Reload". It happened randomly but about 10 times tries. I also added the itemChanged event that why switch to another email can recover this issue. – Andrew May 09 '19 at 13:26
  • @OutlookAdd-insTeam-MSFT I created a test project in [github](https://github.com/andrewzjl/OutlookAssistant/tree/master/WhatIsImportant). Could you please help to have a look? Thanks The issue is related to I want to pin that task pane. Before I change the manifest, I tried to reload window about 20+ times, there is no problem. After use the addHandlerAsync related logic, if I pinned the task pane and switched email then reload by right click. Error is reproduced. – Andrew May 12 '19 at 01:41
  • Confirming that this is a bug on Mac Outlook, we are able to reproduce this. It is a Mac-specific issue and we will be fixing this soon. We'll update this space once it is done. Thanks for reporting. – Outlook Add-ins Team - MSFT May 14 '19 at 15:46
  • Is the bug still open for this? Is there an issue tracked somewhere that I can follow? We are experiencing the same issue currently in our code - verified that it works in the browser but does not work in Mac Outlook. – jadams Mar 05 '21 at 22:09

1 Answers1

1

Please modify your code as such, you aren't really doing anything with that promise.

await new Promise((resolve, reject) => {
    return window.Office.context.mailbox.item.body.getAsync('text', (result) => {
      if (result.status === 'succeeded') {
        console.log(result.value);
        return resolve(result.value);
      } else {
        console.error(result.error);
        return reject(result.error);
      }
    })
  })
Mavi Domates
  • 4,262
  • 2
  • 26
  • 45