1

I need to get all contacts from Microsoft Exchange.. Those contacts are also saved in Office365 -> People -> Directory. Many thx for help!

Mato Skok
  • 29
  • 1
  • 8
  • Stack overflow doesn't solve your problems for you. People are happy to help but you need to put in a good faith effort to get started. – gnicholas May 19 '16 at 02:00

1 Answers1

1

Use the ResolveName("SMTP:") API to retrieve all the contacts from Global Address List, the limitation of such is it only returns the top 100 from the query operation.

Your Managed EWS code works similar to

        var nameResolutionCollection = service.ResolveName("SMTP:");
        foreach(var item in nameResolutionCollection)
        {
            // your code in here
        }

Find out more information from https://msdn.microsoft.com/en-us/library/office/aa563518%28v=exchg.150%29.aspx.

Jackie
  • 2,032
  • 1
  • 12
  • 14
  • The output is like: Horna Milena;SMTP:hornamilenamatejskok@gmail.com
    Stanislav Kopal;SIP:kopal@skoktest.onmicrosoft.com
    Matej Skok;smtp:programator@skoktest.onmicrosoft.com Novak Filip;SMTP:filipnovakmatejskok@gmail.com Skoq Andrej;smtp:skoqandrejmatejsko@skoktest.onmicrosoft.com Slana Sara;SMTP:slanasaramatejskok@gmail.com But it returns only one email in every iteration in foreach loop. I need to get all emails of every person (especially I need to get the SMTP email of every person).
    – Mato Skok May 19 '16 at 07:42
  • >when you say "get all emails of every person", did you mean you could have multiple email addresses for a single person? – Jackie May 19 '16 at 08:07
  • Yes, exactly. There can be more addresses for every user in Exchange. There are addressess of 3 types: a) SMTP b) smtp c) sip I need to get the SMTP address of every person in People -> Dictionary – Mato Skok May 19 '16 at 09:06
  • Not sure if it works, but have you tried service.ResolveName("SIP:")? – Jackie May 19 '16 at 10:07
  • Hi, I have already solved it. `if(nr.Contact.EmailAddresses[EmailAddressKey.EmailAddress1].ToString().Contains("SMTP:")) { pom_SMTPemail = nr.Contact.EmailAddresses[EmailAddressKey.EmailAddress1].ToString(); }` – Mato Skok May 19 '16 at 12:29