0

I have used getAsync method to retrieve the body content which is a asynchronous call.

  // Get the body asynchronous as text
 body.getAsync(Office.CoercionType.Text, function (asyncResult) {
     if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) {
         // We got an error while making the asyn call
     }
     else {
         // Call succeeded do something here
     }
 });

But I want to read the mail content synchronously . How can this be achieved?

Benoit Patra
  • 4,355
  • 5
  • 30
  • 53

1 Answers1

0

Office.js exposes only an asynchronous function so, internally, this should involve some async operation (web request etc.). If you try to call synchronously for code simplicity (yes, synchronous code is easier to read...), I suggest you to have a look at promises.

You may also be interested in this question. Call An Asynchronous Javascript Function Synchronously

Community
  • 1
  • 1
Benoit Patra
  • 4,355
  • 5
  • 30
  • 53