javascript - body.getAsync() 方法上的 Outlook 加载项参数异常

标签 javascript outlook office365 outlook-addin

根据https://dev.outlook.com/reference/add-ins/Body.html : GetAsync() 方法接受 3 个参数。第一个是强制类型,according to their documentation是一个字符串值。 GetAsync 的另外两个参数是选项和回调,它们是可选的。

我的代码:var body = item.body.getAsync("html");

这给出了这个异常(exception):

异常详细信息:outlook-web-16.00.js:formatted:5873 未捕获错误:Sys.ArgumentTypeException:对象无法转换为所需类型。

我是否没有正确使用 getAsync() 方法?我在网上找到的大多数示例代码也都使用回调参数,但如果选项和回调参数是可选的,并且我只需要以 html 形式获取电子邮件正文的内容,这不应该起作用吗? p>

附注这不是 API 版本控制问题。我肯定使用的是 1.3 并且 body.getAsync 不会返回 undefined。

最佳答案

Am I not using the getAsync() method correctly? Most of the example code I've found online are using the callback parameter as well but if the options and callback parameters are optional and I only really need to get the contents of the email body as html, shouldn't this work?

由于此方法是异步的,因此要获取结果,我们必须使用回调。该示例应该可以工作:

Office.context.mailbox.item.body.getAsync("html", processHtmlBody);
 function processHtmlBody(asyncResult) {
    console.log(asyncResult.value)
}

This是一个讨论使用 JavaScript 从异步函数获取返回值的线程。

关于javascript - body.getAsync() 方法上的 Outlook 加载项参数异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38001258/

相关文章:

office365 - 一张幻灯片上有两页以及页码问题

javascript - 如何检测 jquery ajax 请求是否持续超过 5 秒

javascript - 更改 NativeScript TabView 默认行为

javascript - 在函数原型(prototype)中使用 'this' - JavaScript

c# - 如何创建自定义 Outlook 项目?

python - 如何使用office365-rest-python-api从sharepoint下载文件

javascript - fancybox 仅适用于 chrome 和 FF 中的最后一张图像

vba - 从 Excel 发送 Outlook 电子邮件,将最后一行范围文本放在正文中

excel - 将 Outlook 电子邮件中的表复制到 Excel 文件 - VBA

c# - Office 365 电子邮件观察器