"TypeError: item.getAttachmentsAsync is not a function" Outlook add-in office-js with Vue

"TypeError: item.getAttachmentsAsync is not a function" Outlook add-in office-js with Vue

我一直在按照此 link 中的教程进行操作:https://docs.microsoft.com/en-us/javascript/api/outlook/office.messageread?view=outlook-js-preview#getAttachmentContentAsync_attachmentId__options__callback_ 尝试从任务窗格中的 Office 加载项的 outlook 电子邮件中获取附件。我是从 Read 场景而不是 Compose 场景执行此操作的,后者应该可以从 Requirements Set 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]: Error in v-on handler: "TypeError: item.getAttachmentsAsync is not a function"

vue.js:1897 TypeError: item.getAttachmentsAsync is not a function at 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)

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

outlook-addin Office.AttachmentContent interface not working

谢谢,如有任何建议,我们将不胜感激。

Office.context.mailbox.item.getAttachmentsAsync is only available in Compose mode. If you are working from the Read scenario, you can use the attachments property 在 Office.MessageRead 界面上获取项目的附件。

例如:

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

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