0
votes

I have several user accounts in Office 365 tenant. Two of them are almost identical (have similar settings but different contact info and name). I try to fetch information (such as all folders and items) in user's mailbox using GetFolder 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:PrimarySmtpAddress>[email protected]</t:PrimarySmtpAddress>
      </t:ConnectingSID>
    </t:ExchangeImpersonation>
  </soap:Header>
  <soap:Body>
    <GetFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
         xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <FolderShape>
        <t:BaseShape>AllProperties</t:BaseShape>
        <t:AdditionalProperties> </t:AdditionalProperties>
      </FolderShape>
      <FolderIds>
        <t:DistinguishedFolderId Id="outbox"/>
      </FolderIds>
    </GetFolder>
  </soap:Body>
</soap:Envelope>

I can successfully get info for one of these two mailboxes but when 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:Body>
    <s:Fault>
      <faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorNonPrimarySmtpAddress</faultcode>
      <faultstring xml:lang="en-US">The primary SMTP address must be specified when referencing a mailbox.</faultstring>
      <detail>
        <e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorNonPrimarySmtpAddress</e:ResponseCode>
        <e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">The primary SMTP address must be specified when referencing a mailbox.</e:Message>
        <t:MessageXml xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
          <t:Value Name="Primary"/>
        </t:MessageXml>
      </detail>
    </s:Fault>
  </s:Body>
</s:Envelope>

Why do I get such ErrorNonPrimarySmtpAddress error response? What can be the problem when I fetch data in the mailbox of the second user?

1
What is the request that returns that error? Are you specifying the primary SMTP address rather one of the proxy SMTP addresses?Dmitry Streblechenko
@DmitryStreblechenko I've just updated the description and provided EWS GetFolder operation body that I use when I fetch info about folder in user mailbox.Vasyl

1 Answers

0
votes

You need to use the primary SMTP address - I doubt [email protected] is the primary address.

Open the address book in Outlook (Ctrl+Shift+B), open the user, switch to the "E-mail Addresses" tab, look for the address with the "SMTP:" prefix (note the caps).