0
votes

I try to delete email with EWS request. So I use this documentation to do my request https://msdn.microsoft.com/en-us/library/office/aa580484(v=exchg.150).aspx

It's my soap request

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 >';

And I have this answer

<?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>

I understand my add-in didn't have the permission to delete an item. But my add-in have already a ReadWriteMailbox permision. So what I can do more to delete a item with EWS request ?

1

1 Answers

2
votes

As Per Table 1 in https://msdn.microsoft.com/en-us/library/office/jj190901(v=exchg.150).aspx the DeleteItem operation isn't available in Mail Apps for Outlook using makeEwsRequestAsync which is why you get that error. You don't really want a Mail Apps being able to delete Mailbox data because of the risk of a badly written app removing data it shouldn't whether on purpose or by accident. If you have a legitimate reason to delete data they use a Move instead eg you could move and Item into a processed folder in the Mailbox and then age the content out of that folder using a Folder Retention tags etc (you could also just move the Item into the DeleteItems folder in a Mailbox as a workaround).