使用 EWS 请求拒绝访问以删除项目

Access Denied to delete an item with EWS request

我尝试删除带有 EWS 请求的电子邮件。所以我使用此文档来满足我的要求 https://msdn.microsoft.com/en-us/library/office/aa580484(v=exchg.150).aspx

这是我的肥皂请求

var soapToDeleteItem =
                '<?xml version= "1.0" encoding= "utf-8" ?>' +
                ' <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
                ' xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">' +
                '    <soap:Body>' +
                '        <DeleteItem DeleteType="MoveToDeletedItems" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">' +
                '            <ItemIds>' +
                '                <t:ItemId Id="'+ item_id + '" ChangeKey="' + changeKey + '" />' +
                '            </ItemIds>' +
                '        </DeleteItem>' +
                '    </soap:Body >' +
                ' </soap: Envelope >';

我有这个答案

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <s:Fault>
            <faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorAccessDenied</faultcode>
            <faultstring xml:lang="en-US">The requested web method is unavailable to this caller or application.</faultstring>
            <detail>
                <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorAccessDenied</e:ResponseCode>
                <e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The requested web method is unavailable to this caller or application.</e:Message>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

我了解我的加载项没有删除项目的权限。但是我的加载项已经有 ReadWriteMailbox 权限。那么我还能做些什么来删除带有 EWS 请求的项目?

根据 Table 1 in https://msdn.microsoft.com/en-us/library/office/jj190901(v=exchg.150).aspx,DeleteItem 操作在使用 makeEwsRequestAsync 的 Outlook 邮件应用程序中不可用,这就是您收到该错误的原因。您真的不希望邮件应用程序能够删除邮箱数据,因为编写错误的应用程序存在删除数据的风险,无论是有意还是无意。如果您有正当理由删除数据,他们会改用移动,例如,您可以将项目移动到邮箱中已处理的文件夹中,然后使用文件夹保留标签等将内容从该文件​​夹中移出(您也可以只移动项目进入邮箱中的 DeleteItems 文件夹作为解决方法)。