Outlook加载项:使用EWS获取共享邮箱ItemAttachment [英] Outlook add-in : Get shared mailbox ItemAttachment using EWS

查看:256
本文介绍了Outlook加载项:使用EWS获取共享邮箱ItemAttachment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在大多数情况下,我们的Outlook外接程序都可以在共享邮箱上使用,除非电子邮件中的附件的类型为"Office.MailboxEnums.AttachmentType.Item",例如".msg"文件.

Our outlook add-in works in most scenarios on a shared Mailbox, except when the attachment in an email is of type "Office.MailboxEnums.AttachmentType.Item" e.g ".msg" file.

Environment is Outlook web and desktop.

我们大多通过REST获得所有附件内容,因为它们以base-64的形式返回,但带有"AttachmentType.Item"正文是电子邮件正文,而不是base-64.在这种情况下,我们调用EWS下载该附件,处理正文并以byte [];

We mostly get all attachment content via REST, as they are returned as base-64, but with "AttachmentType.Item" the body is email body and not a base-64. In this case, we make a call to EWS to download that attachment, process the body and return as byte[];

我们当前遇到的问题是,当附件的类型为".msg"时,在共享邮箱上,EWS返回错误"ErrorAccessDenied",这很奇怪,因为下载了其他附件,并且我们确保已传递"TargetMailbox"

The problem we are currently having is that, when the attachment is of type ".msg" on a shared mailbox, EWS return with the error "ErrorAccessDenied", This is strange as, other attachments are downloaded and we've made sure that we pass "TargetMailbox"

我们通过以下方式获取targetMailbox: https ://docs.microsoft.com/zh-cn/office/dev/add-ins/outlook/delegate-access

We get the targetMailbox by: https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/delegate-access

一旦有了accessToken和targetMailbox,我们就称其为后端

Once we have the accessToken and targetMailbox we call the backend

GetData(token, Id){
    let sharedMailBox = GetTargetMailbox(token);
    return this.$http.post("DownloadAttachment", {
        token: sharedMailBox.token,
        url: Office.context.mailbox.ewsUrl,
        attachmentId: Id,
        mailbox: sharedMailBox.mailbox
    }, {
        responseType: 'arraybuffer',
    }).then(response => response.data);
}

后端

 DownloadAttachment(Request request){
            var service = new ExchangeService
            {
                Credentials = request.token,
                Url = request.url
            };
            
            if (request.mailbox != "")
            {
                FolderId SharedMailbox = new FolderId(WellKnownFolderName.Inbox, request.TargetMailbox);
                ItemView itemView = new ItemView(1);
                service.FindItems(SharedMailbox, itemView); //This throws ErrorAccessDenied
            }
        
            //do other stuff and return data
        
}

不确定,该如何获取共享邮箱的itemAttachment.

Not sure, what to do to get the itemAttachment for Shared mailbox.

推荐答案

共享邮箱不支持EWS,仅REST支持.这可能在我们的文档中被漏掉了.我们将对其进行更新.要通过REST获取项目附件,请遵循

EWS is not supported in a shared mailbox, only REST. This might have been missed out in our documentation. We'll update it. To get item attachment via REST, follow "Get MIME content of an Outlook message attached to an Outlook item or group post" in https://docs.microsoft.com/en-us/graph/outlook-get-mime-message

这篇关于Outlook加载项:使用EWS获取共享邮箱ItemAttachment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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