Selva
Selva

Reputation: 986

Get Contacts folder items using ews in office 365

I'm using the following SOAP request to retrieve the items in contacts folder in office 365 mail addin

'<?xml version="1.0" encoding="UTF-8"?>'+
    ' <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
     ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"' +
            ' xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"'+
            ' xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">'+
    ' <soap:Header>'+
       ' <t:RequestServerVersion Version="Exchange2013" />' +
    ' </soap:Header>'+
    ' <soap:Body >'+
       ' <m:FindPeople>'+
          ' <m:IndexedPageItemView BasePoint="Beginning" MaxEntriesReturned="100" Offset="0"/>'+
          ' <m:ParentFolderId>'+
             ' <t:DistinguishedFolderId Id="contacts"/>'+
          ' </m:ParentFolderId>'+
      ' </m:FindPeople>'+
    ' </soap:Body>'+
    ' </soap:Envelope>';

But the following error shows up.

error

I have used FindItem , GetFolder methods for calendar folder and those are working.

Is there anyway to look for people email address by using the name as search value.

Upvotes: 0

Views: 804

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

the makeEwsRequestAsync in Mail Apps only supports a subset of EWS operations which FindPeople is not one of. You can see a full list of supported operations on https://msdn.microsoft.com/en-us/library/office/fp160952.aspx .

Is there anyway to look for people email address by using the name as search value.

Sure just use a FindItem with a restriction on the DisplayName eg

<?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://sc
hemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xml
soap.org/soap/envelope/">
  <soap:Header>
    <t:RequestServerVersion Version="Exchange2013_SP1" />
  </soap:Header>
  <soap:Body>
    <m:FindItem Traversal="Shallow">
      <m:ItemShape>
        <t:BaseShape>AllProperties</t:BaseShape>
      </m:ItemShape>
      <m:IndexedPageItemView MaxEntriesReturned="1000" Offset="0" BasePoint="Beginning" />
      <m:Restriction>
        <t:Contains ContainmentMode="Substring" ContainmentComparison="IgnoreCase">
          <t:FieldURI FieldURI="contacts:DisplayName" />
          <t:Constant Value="Blah blah" />
        </t:Contains>
      </m:Restriction>
      <m:ParentFolderIds>
        <t:DistinguishedFolderId Id="contacts" />
      </m:ParentFolderIds>
    </m:FindItem>
  </soap:Body>
</soap:Envelope>

Cheers Glen

Upvotes: 1

Related Questions