Outlook Addin and EWS GetAttachment RRS feed

  • Question

  • So I'm roughly following the GetAttachment Example from Microsoft --

    But, my WebService that receives the EWS Token, EWS URL, and Attachment ID is written in Python.  My problem seems to be to a permission error.  When I try to retrieve the Attachment by ID using an EWS Soap request, I an ErrorItemNotFound response.

    Here is what I have working.

    I have an Outlook AddIn written in Javascript that responds to mail item selections.  

    I retrieve an EWS Token using the isRest=false option: 

    Office.context.mailbox.getCallbackTokenAsync(getEWSCallback, options);

    For mail that has an attachment, I extract information about the attachment including the attachment Id. 

    Here is a sample of the attachment information:

    "name": "xxxxxxxxxxx.docx",
    "contentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
    "size": 162008,
    "attachmentType": 0,
    "isInline": false

    I pass the EWS Token, EWS Url, and Attachment information to my webservice; which is written in Python.  

    My WebService constructs the soap request:

    <style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000} span.s1 {font-variant-ligatures: no-common-ligatures} </style>

    <?xml version="1.0" encoding="utf-8"?>

    <soap:Envelope xmlns:xsi=""





    <t:RequestServerVersion Version="Exchange2013" />



        <GetAttachment xmlns=""




            <t:AttachmentId Id="XZkADdlMDAxOTFiLWZmMWYtNGI1Ni1iYmM2LTlhOTJjYTBmMTI1MQBGAAAAAAAO1b910PexQpLkqgde51DABwAyR2+p4hG4RbXOV7pJuYtiAAAAAAEMAAAyR2+p4hG4RbXOV7pJuYtiAABsXaGoAAABEgAQAJ8Lans/ZeZLrkpk6mQ/QQg="/>





    I then send a Webrequest with python:

    authHeaders = {
    'Authorization': "Bearer " + ewsToken,
    'Content-type': 'text/xml; charset=utf-8'
    webResp =, headers=authHeaders, data=requestString)

    The response I get is below:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="">
    <h:ServerVersionInfo MajorVersion="15" MinorVersion="20" MajorBuildNumber="2430" MinorBuildNumber="27" Version="V2018_01_08"
    <m:GetAttachmentResponse xmlns:m=""
    <m:GetAttachmentResponseMessage ResponseClass="Error">
    <m:MessageText>The specified object was not found in the store., The process failed to get the correct properties.</m:MessageText>

    My understanding is that the ErrorItemNotFound response indicates either (1) The item doesn't exists or (2) I don't have permission to access it.

    If I use a corrupt EWS Token, I get a Http 401 error that indicates I'm not authorized to make the EWS Post.  So I believe the Bearer authentication is working correctly.

    Any thoughts or help?

    Thank you,


    Monday, November 11, 2019 7:27 PM