'getAsync' returns 'Office.context.mailbox.item.body.getAsync is not a function'
'getAsync' returns 'Office.context.mailbox.item.body.getAsync is not a function'
我目前正在使用 Javascript API 研究 Outlook 加载项的 Microsoft 文档,并下载了 Microsoft 提供的示例之一,特别是 'outlook-add-in-command-demo' 来自 Github.
然后我在 61 行 event.completed();
之前修改了 FunctionFile\Function.js
(file) 并添加了以下内容:
Office.context.mailbox.item.body.replaceAsync(
'Hello world!',
{ coercionType: Office.CoercionType.Text },
function callback(result) {
});
这段代码来自 API 文档本身 replaceAsync
(docs)
测试加载项功能时,我在开发人员控制台上收到以下错误:
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
同一文件的第 53 行包含对 Office API 的类似调用,并且此调用没有问题 (var subject = Office.context.mailbox.item.subject;
)。但是 replaceAsync
、getAsync
、setAsync
和其他人只会产生相同的错误。
有什么线索吗?
Office.context.mailbox.item.subject 是读 API。如果可行,您可能正在尝试在阅读模式下使用撰写模式 API。 body.replaceAsync() 和 body.setAsync() 在邮件阅读中不起作用。您能否确认您正在尝试在撰写模式下使用这些 API?您能否也提供您用于 body.getAsync(...) 的代码?应该可以。
我目前正在使用 Javascript API 研究 Outlook 加载项的 Microsoft 文档,并下载了 Microsoft 提供的示例之一,特别是 'outlook-add-in-command-demo' 来自 Github.
然后我在 61 行 event.completed();
之前修改了 FunctionFile\Function.js
(file) 并添加了以下内容:
Office.context.mailbox.item.body.replaceAsync(
'Hello world!',
{ coercionType: Office.CoercionType.Text },
function callback(result) {
});
这段代码来自 API 文档本身 replaceAsync
(docs)
测试加载项功能时,我在开发人员控制台上收到以下错误:
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
同一文件的第 53 行包含对 Office API 的类似调用,并且此调用没有问题 (var subject = Office.context.mailbox.item.subject;
)。但是 replaceAsync
、getAsync
、setAsync
和其他人只会产生相同的错误。
有什么线索吗?
Office.context.mailbox.item.subject 是读 API。如果可行,您可能正在尝试在阅读模式下使用撰写模式 API。 body.replaceAsync() 和 body.setAsync() 在邮件阅读中不起作用。您能否确认您正在尝试在撰写模式下使用这些 API?您能否也提供您用于 body.getAsync(...) 的代码?应该可以。