These are chat archives for OfficeDev/ews-java-api

12th
Nov 2018
medhanafi
@medhanafi
Nov 12 2018 09:20
I try only to get inbox item count with this code
public class EwsService extends AbstractService {

    private ExchangeService service;


    public EwsService() {
            this.service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

    }

    /**
     * Open a ews connection and return number of inbox's item
     * 
     * @return INBOX item
     * @throws Exception
     */
    public String testService() throws Exception {
        try {
            service.setCredentials(new WebCredentials("username@domain.com", "password", "domain.com"));
            service.setUrl(new URI("https://xxxxxxxxxxxxxxxxxx.com/ews/Exchange.asmx"));
            Folder inbox = new Folder(this.service);
            inbox = Folder.bind(service, WellKnownFolderName.Inbox);
            return new StringBuilder("INBOX (").append(inbox.getTotalCount()).append(")").toString();

        } catch (Exception e) {
            this.getLogger().warn("Error occured ", e);
        }
        return "{error}";
    }

}