0
votes

I have several user accounts in Office 365 tenant with licences assigned. When I try to fetch information (such as all folders and items) in user's mailbox using FindFolder operation from EWS API that contains next body:

<?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:Header>
    <t:RequestServerVersion Version="Exchange2013"/>
    <t:ExchangeImpersonation>
      <t:ConnectingSID>
        <t:PrincipalName>[email protected]</t:PrincipalName>
      </t:ConnectingSID>
    </t:ExchangeImpersonation>
  </soap:Header>
  <soap:Body>
    <FindFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" Traversal="Shallow">
      <FolderShape>
        <t:BaseShape>AllProperties</t:BaseShape>
      </FolderShape>
      <IndexedPageFolderView MaxEntriesReturned="1000" BasePoint="Beginning" Offset="0"/>
      <ParentFolderIds>
        <t:DistinguishedFolderId Id="msgfolderroot"/>
      </ParentFolderIds>
    </FindFolder>
  </soap:Body>
</soap:Envelope>

([email protected] is user principal name of target Office 365 account) I get an error reply with the next body:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <h:ServerVersionInfo MajorVersion="15" MinorVersion="20" MajorBuildNumber="1601" MinorBuildNumber="24" Version="V2018_01_08" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
  </s:Header>
  <s:Body>
    <m:FindFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <m:ResponseMessages>
        <m:FindFolderResponseMessage ResponseClass="Error">
          <m:MessageText>Mailbox does not exist.</m:MessageText>
          <m:ResponseCode>ErrorNonExistentMailbox</m:ResponseCode>
          <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
        </m:FindFolderResponseMessage>
      </m:ResponseMessages>
    </m:FindFolderResponse>
  </s:Body>
</s:Envelope>

GetFolder operation gives me the same result.

This error is commonly caused by an unlicensed mailbox account. But all my users have active Exchange licence. Why do I get such ErrorNonExistentMailbox error response?

2
Are you specify the primary SMTP address of the mailbox or one of the proxy ones?Dmitry Streblechenko
I use upn (user principal name).Vasyl

2 Answers

0
votes

Make sure the account running the EWS script has ApplicationImpersonation permissions. So in this case your account should have ApplicationImpersonation permissions.

  • Navigate to the EAC in O365 > Permissions > add ApplicationImpersonation to the HygeneManagement RBAC Group and then add yourself as a member. This should resolve the issue.

In the future if you ever want to TroubleShoot on ApplicationImpersonation you can use EXRCA (https://testconnectivity.microsoft.com/) > O365 tab > Microsoft Exchange Web Services Connectivity Tests > select "Service Account Access (Developers)" and run the test.

Let me know if you have any further questions.

0
votes

I had this problem when I used the exchange service, the mailbox bans the requests after some requests (I do not know why?!). (for me after 200 requests)