Search code examples
pythonsoapexchangewebservices

Error message when accessing inbox as delegate by using EWS


I'm currently trying to access a mailbox that has been shared with me as delegate as described in the documentation. With the request (from the documentation),

<?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=" Exchange2007_SP1" />
      </soap:Header>
      <soap:Body>
        <m:CreateItem MessageDisposition="SaveOnly">
          <m:SavedItemFolderId>
            <t:DistinguishedFolderId Id="drafts">
              <t:Mailbox>
                <t:EmailAddress>email of my inbox</t:EmailAddress>
              </t:Mailbox>
            </t:DistinguishedFolderId>
          </m:SavedItemFolderId>
          <m:Items>
            <t:Message>
              <t:Subject>Company Soccer Team</t:Subject>
              <t:Body BodyType="HTML">Are you interested in joining?</t:Body>
              <t:ToRecipients>
                <t:Mailbox>
                  <t:EmailAddress>inbox I want to access</t:EmailAddress>
                </t:Mailbox>
              </t:ToRecipients>
            </t:Message>
          </m:Items>
        </m:CreateItem>
      </soap:Body>
    </soap:Envelope>

I always receive the response

    <?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Header>
      <h:ServerVersionInfo 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" MajorVersion="15" MinorVersion="20" MajorBuildNumber="2430" MinorBuildNumber="27" Version="V2018_01_08" />
   </s:Header>
   <s:Body>
      <m:FindFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="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">
         <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>

Does someone know why the response says that the mailbox does not exists? Within Outlook, I can access this mailbox without any problem.


Solution

  • The error message was thrown because one of the mailboxes was hosted on Exchange Online and the other was on premise.