gpt4 book ai didi

vue.js - "TypeError: item.getAttachmentsAsync is not a function"Outlook插件office-js with Vue

转载 作者:行者123 更新时间:2023-12-05 06:49:28 27 4
gpt4 key购买 nike

我一直在关注此链接中的教程:https://learn.microsoft.com/en-us/javascript/api/outlook/office.messageread?view=outlook-js-preview#getAttachmentContentAsync_attachmentId__options__callback_尝试从任务 Pane 中的 Office 加载项的 outlook 电子邮件中获取附件。我是从 Read 场景而不是 Compose 场景执行此操作的,后者应该可从 Requirements Set 1.8 获得。

我已将 list 中的要求集更新为 1.8

    <Requirements>
<Sets>
<Set Name="Mailbox" MinVersion="1.8"/>
</Sets>
</Requirements>

以及更新版本覆盖需求集

    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
<Requirements>
<bt:Sets DefaultMinVersion="1.8">
<bt:Set Name="Mailbox"/>
</bt:Sets>
</Requirements>

在我的 Vue 文件中,这是我的代码:

mounted()
{
this.loading = true;
var item = Office.context.mailbox.item;

console.log(item);
var options = {asyncContext: {currentItem: item}};
item.getAttachmentsAsync(options, callback);

function callback(result)
{
console.log("inside callback");
console.log(result.value.length)
if (result.value.length > 0)
{
for (let i = 0; i < result.value.length; i++)
{
result.asyncContext.currentItem.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback);
console.log("function callback");
console.log(result.value[i].id);
}
}
}

function handleAttachmentsCallback(result)
{
console.log("item attachment handler");
// Parse string to be a url, an .eml file, a base64-encoded string, or an .icalendar file.
switch (result.value.format)
{
case Office.MailboxEnums.AttachmentContentFormat.Base64:
// Handle file attachment.
console.log("got base 64");
console.log("result ----------" + result.value);
_this.sendRequest(result.value)
break;
case Office.MailboxEnums.AttachmentContentFormat.Eml:
// Handle email item attachment.
break;
case Office.MailboxEnums.AttachmentContentFormat.ICalendar:
// Handle .icalender attachment.
break;
case Office.MailboxEnums.AttachmentContentFormat.Url:
// Handle cloud attachment.
break;
default:
// Handle attachment formats that are not supported.
}
}
}

当我运行它时,出现以下错误:

vue.js:634 [Vue warn]: Error in v-on handler: "TypeError: item.getAttachmentsAsync is not a function"

vue.js:1897 TypeError: item.getAttachmentsAsync is not a functionat VueComponent.mounted (getAttachments.vue:265)at click (getAttachments.vue?ccdf:99)at invokeWithErrorHandling (vue.js:1863)at HTMLButtonElement.invoker (vue.js:2188)at HTMLButtonElement.original._wrapper (vue.js:7547)

我已经尝试了所有这些,但都没有解决问题,我什至尝试手动获取附件数据,但没有成功。因为它在控制台中显示了附件数据,但由于错误而没有进一步显示。

outlook-addin Office.AttachmentContent interface not working

How get attachments in outlook plugin?

谢谢,任何建议都表示赞赏。

最佳答案

Office.context.mailbox.item.getAttachmentsAsync仅在撰写模式下可用。如果您在读取方案中工作,则可以使用 attachments property在 Office.MessageRead 接口(interface)上获取项目的附件。

例如:

Office.context.mailbox.item.attachments[0].id

将是项目上第一个附件的附件 ID。

关于vue.js - "TypeError: item.getAttachmentsAsync is not a function"Outlook插件office-js with Vue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66601445/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com