Outlook加载项Office.AttachmentContent接口不起作用 [英] outlook-addin Office.AttachmentContent interface not working

查看:52
本文介绍了Outlook加载项Office.AttachmentContent接口不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Outlook插件中,我试图从活动的电子邮件中获取附件.

In my outlook-addin I am trying to get the attachments from the active e-mail message.

我复制粘贴了以下示例: https://docs.microsoft.com/en-us/javascript/api/outlook/office.attachmentcontent?view=outlook-js-preview

I copy pasted the example from: https://docs.microsoft.com/en-us/javascript/api/outlook/office.attachmentcontent?view=outlook-js-preview

确切的示例代码:

var item = Office.context.mailbox.item;
var options = {asyncContext: {currentItem: item}};
item.getAttachmentsAsync(options, callback);

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

function handleAttachmentsCallback(result) {
    // 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.
            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.
    }
}

加载项启动后,我收到一条错误消息,提示 item.getAttachmentsAsync 不是函数.

yet upon addin launch I get an error saying item.getAttachmentsAsync is not a function.

我在API文档中寻求帮助,但找不到有关此问题的任何信息.

I looked in the API docs for help but can't find any information on this issue.

有任何线索吗?也许您也遇到了这个问题?

Any clues? maybe you encountered this problem too?

推荐答案

如@ outlook-add-ins-team-msft所述:getAttachmentsAsync是仅撰写模式的API.

As noted by @outlook-add-ins-team-msft : getAttachmentsAsync is a compose mode only API.

以下是使用api中正确方法的后续问题.

Here is a follow up question using the right methods from the api.

Office插件getAttachementContentAsync无法加载CORS问题

这篇关于Outlook加载项Office.AttachmentContent接口不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆