我一直在关注此链接中的教程:https://learn.microsoft.com/en-us/javascript/api/outlook/office.messageread?view=outlook-js-preview#getAttachmentContentAsync_attachmentId__options__callback_ https://learn.microsoft.com/en-us/javascript/api/outlook/office.messageread?view=outlook-js-preview#getAttachmentContentAsync_attachmentId__options__callback_尝试从任务窗格中的 Office 加载项的 Outlook 电子邮件中获取附件。我是在读取场景中执行此操作,而不是在要求集 1.8 中提供的撰写场景中执行此操作。
我已将清单中的要求集更新为 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]: v-on 处理程序中出现错误:“TypeError: item.getAttachmentsAsync 不是函数”
vue.js:1897 TypeError: item.getAttachmentsAsync 不是函数
在 VueComponent.mounted (getAttachments.vue:265)
单击时 (getAttachments.vue?ccdf:99)
在 invokeWithErrorHandling (vue.js:1863)
在 HTMLButtonElement.invoker (vue.js:2188)
在 HTMLButtonElement.original._wrapper (vue.js:7547)
我已经尝试了所有这些,但都没有解决问题,我什至尝试手动获取附件数据,但没有成功。因为它在控制台中显示附件数据,但由于错误而无法进一步进行。
Outlook-addin Office.AttachmentContent 界面不起作用 https://stackoverflow.com/questions/60057723/outlook-addin-office-attachmentcontent-interface-not-working
如何在outlook插件中获取附件? https://stackoverflow.com/questions/65679858/how-get-attachments-in-outlook-plugin
谢谢,任何建议表示赞赏。