none
How to get contacts in Directory folder? RRS feed

  • Question

  • Hi everyone,

    I can get all contacts from Your Contacts folder successfully.

    How can I get all contacts in that Directory folder from EWS?

    I tried this code but it throws this error:

    Exception: The distinguished folder name is unrecognized.

    ews.EwsLogging.DebugLogEnabled = false;
    let exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013);
    
    exch.Credentials = new ews.ExchangeCredentials("username", "password");
    
    exch.Url = new ews.Uri("https://outlook.office365.com/Ews/Exchange.asmx");
    
    exch.FindItems(
        [
            new ews.FolderId(ews.WellKnownFolderName.Directory) // Changed .Contacts to .Directory
        ],
        null,
        null,
        new ews.ItemView(10),
        null,
        ews.ServiceErrorHandling.ReturnErrors
    ).then(function (resp) {
        resp.Responses[0].Results.Items.forEach(function (item) {
            console.log(item.EmailAddresses.Entries.Values);
        });
    }, function (ei) {
        console.log(ei.stack, ei.stack.split("\n"));
    });

    Note: I'm using ews-javascript-api. But a general solution is more than enough.

    I just need to know a way to solve this problem.

    Thank you.



    • Edited by piavgh Friday, April 6, 2018 1:31 PM
    Friday, April 6, 2018 1:31 PM