none
Outlook Addin - Calling EWS CreateAttachment gives ErrorAccessDenied RRS feed

  • Question

  • I am developing an Outlook add in (command addin). In the manifest I well put:

    <Permissions>ReadWriteMailbox</Permissions>

    Then in the JavaScript there is a button that just passes the ewsURL, the token id, and itemID (using AJAX) to the server... the server uses this information use EWS calls using SOAP.

    At this point I am debugging and I am using an Office 365 account, I take an email in my inbox... the Project runs in my localhost computer.

    I use this XML EWS request:

    @"<?xml version=""1.0"" encoding=""utf-8""?>
    <soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
                   xmlns:m=""http://schemas.microsoft.com/exchange/services/2006/messages""
                   xmlns:t=""http://schemas.microsoft.com/exchange/services/2006/types""
                   xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
      <soap:Header>
        <t:RequestServerVersion Version=""Exchange2013"" />
        <t:TimeZoneContext>
          <t:TimeZoneDefinition Id=""Central Standard Time"" />
        </t:TimeZoneContext>
      </soap:Header>
      <soap:Body>
        <m:CreateAttachment>
          <m:ParentItemId Id=""{0}"" />
          <m:Attachments>
            <t:FileAttachment>
              <t:Name>{1}</t:Name>
              <t:Content>{2}=</t:Content>
            </t:FileAttachment>
          </m:Attachments>
        </m:CreateAttachment>
      </soap:Body>
    </soap:Envelope>";

    {0} {1} and {2} are replaced accordingly.

    I get:

    ErrorAccessDenied - The requested web method is unavailable to this caller or application.

    Am I allowed to call CreateAttachments using the token ID that I get when calling Office.context.mailbox.getCallbackTokenAsync?

    Again, one part of the code is the JavaScript that gets this data:
    Office.context.mailbox.getCallbackTokenAsync
    Office.context.mailbox.ewsUrl
    Office.context.mailbox.item.itemId

    It passes this information to an .aspx .NET Project that in the Page_Load event does the EWS/SOAP request to the Office 3656 server...

    I can well get attachments, download them, but I cannot add attachments to existing items (inbox).

    I need to transform existing attachments (e.g. an Antivirus should be a typical example of converting one attachment into a "this file has a virus" content attachment).

    Thanks.

    Wednesday, September 20, 2017 1:45 PM

All replies