Reputation: 334
I'm currently researching the Microsoft documentation for Outlook add-ins using the Javascript API and downloaded one of the samples provided by Microsoft, specifically the 'outlook-add-in-command-demo' from Github.
I then modified FunctionFile\Function.js
(file) on line 61 just before event.completed();
and added the following:
Office.context.mailbox.item.body.replaceAsync(
'Hello world!',
{ coercionType: Office.CoercionType.Text },
function callback(result) {
});
This bit of code comes from the API documentation itself replaceAsync
(docs)
When testing the add-in functionality I get the following error on the Developer Console:
Uncaught TypeError: Office.context.mailbox.item.body.replaceAsync is not a function at Object.getSubject [as callback] (Functions.js:62) at outlook-web-16.01.js:16
Line 53 of the same file includes a similar call to the Office API and this one works without a problem (var subject = Office.context.mailbox.item.subject;
). But replaceAsync
, getAsync
, setAsync
and others just produce the same error.
Any clues?
Upvotes: 0
Views: 2525
Reputation:
Office.context.mailbox.item.subject is a read API. If that works, you're probably trying to use a compose mode API in read mode. body.replaceAsync() and body.setAsync() do not work in mail read. Can you confirm that you are trying these APIs in compose mode? Could you also provide the code you used for body.getAsync(...)? That should work.
Upvotes: 3