none
Get Contacts folder items using ews in office 365 RRS feed

  • Question

  • 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.

    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.

    Tuesday, August 18, 2015 12:57 PM

Answers

  • Hi Selva,

    >> . Is there a way to get the email address in place of names, or a method to convert names to email address ?

    I agree with Tony, you could use GetItem operation to get the current email address, and you do not need to use FindItem methods, you could just pass ItemId to get the from email and to email address.
    Here is a simple dmeo:

    //soap
    function getItem(id)
    {
        // Return a GetItem operation request for the subject of the specified item. 
        var result =
                    '<?xml version="1.0" encoding="utf-8"?> ' +
                    '<soap:Envelope ' +
                    '  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
                    '  xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
                    '  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" ' +
                    '  xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
                    '  <soap:Header> '+
                    '<t:RequestServerVersion Version="Exchange2013" />'+
                    ' </soap:Header> '+
                    '  <soap:Body>' +
                    '    <GetItem ' +
                    '      xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" ' +
                    '      xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
                    '      <ItemShape> ' +
                    '        <t:BaseShape>Default</t:BaseShape> ' +
                    '        <t:IncludeMimeContent>true</t:IncludeMimeContent> ' +
                    '      </ItemShape> ' +
                    '      <ItemIds> ' +
                    ' <t:ItemId Id="'+id+'" />' +
                    '      </ItemIds> ' +
                    '    </GetItem> ' +
                    '  </soap:Body> ' +
                    '</soap:Envelope>'
        return result;
    }
    //makeewsrequest
    function GetItem()
    {
        // Create a local variable that contains the mailbox.
        var mailbox = Office.context.mailbox;
        mailbox.makeEwsRequestAsync(getItem(mailbox.item.itemId), callback);
    }
    //callback
    function callback(asyncResult) {
        var result = asyncResult.value;
        var context = asyncResult.context;
    
    }

    In the result, you could get the email address.

    Best Regards,

    Edward

       

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, August 26, 2015 8:45 AM

All replies

  • Hi,

    FindPeople is not a supported method from makeEwsRequest. Have you tried using our REST APIs though?

    Wednesday, August 19, 2015 1:09 AM
  • Hi Andrew,

    When I use REST API, I struck with CORS origin issue. 

    When I use FindItem method, I was able to get the appointments but the attendees (DisplayTo) gives names instead of email address. Is there a way to get the email address in place of names, or a method to convert names to email address ?

    As mentioned here , I tried using ResolveNames method, but the error "The requested method is unavailable to this caller" is showing up. Is this method recently being restricted or am I missing something ? 


    Wednesday, August 19, 2015 2:12 AM
  • Hi Selva,

    >> I tried using ResolveNames method, but the error "The requested method is unavailable to this caller" is showing up. Is this method recently being restricted or am I missing something ?

    It was caused by that ResolveNames method is not supported in makeEwsRequestAsync method. For supported EWS operations in makeEwsRequestAsync method, you could refer the link below:
    #Table 2. Supported EWS operations
    https://msdn.microsoft.com/en-us/library/office/fp160952.aspx

    >> Is there a way to get the email address in place of names, or a method to convert names to email address ?
    With FindItem method, you would not get the email address. I think you could try to get ItemID with  FindItem method, and use GetItem operation with ItemID to get ToRecipients which contains EmailAddress.
    # GetItem operation (email message)
    https://msdn.microsoft.com/en-us/library/office/aa566013.aspx

    Best Regards,

    Tony


    Help each other

    Thursday, August 20, 2015 7:32 AM
  • Hi Selva,

    >> . Is there a way to get the email address in place of names, or a method to convert names to email address ?

    I agree with Tony, you could use GetItem operation to get the current email address, and you do not need to use FindItem methods, you could just pass ItemId to get the from email and to email address.
    Here is a simple dmeo:

    //soap
    function getItem(id)
    {
        // Return a GetItem operation request for the subject of the specified item. 
        var result =
                    '<?xml version="1.0" encoding="utf-8"?> ' +
                    '<soap:Envelope ' +
                    '  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
                    '  xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
                    '  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" ' +
                    '  xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
                    '  <soap:Header> '+
                    '<t:RequestServerVersion Version="Exchange2013" />'+
                    ' </soap:Header> '+
                    '  <soap:Body>' +
                    '    <GetItem ' +
                    '      xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" ' +
                    '      xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"> ' +
                    '      <ItemShape> ' +
                    '        <t:BaseShape>Default</t:BaseShape> ' +
                    '        <t:IncludeMimeContent>true</t:IncludeMimeContent> ' +
                    '      </ItemShape> ' +
                    '      <ItemIds> ' +
                    ' <t:ItemId Id="'+id+'" />' +
                    '      </ItemIds> ' +
                    '    </GetItem> ' +
                    '  </soap:Body> ' +
                    '</soap:Envelope>'
        return result;
    }
    //makeewsrequest
    function GetItem()
    {
        // Create a local variable that contains the mailbox.
        var mailbox = Office.context.mailbox;
        mailbox.makeEwsRequestAsync(getItem(mailbox.item.itemId), callback);
    }
    //callback
    function callback(asyncResult) {
        var result = asyncResult.value;
        var context = asyncResult.context;
    
    }

    In the result, you could get the email address.

    Best Regards,

    Edward

       

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, August 26, 2015 8:45 AM