【问题标题】:Get calendar events from Outlook.com using Java API使用 Java API 从 Outlook.com 获取日历事件
【发布时间】:2016-07-30 08:59:49
【问题描述】:

我想使用 Java API 从 Outlook.com 获取所有日历事件。我测试了这段代码来连接:

 public void findChildFolders(String username, String password) throws Exception
    {
        ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
        ExchangeCredentials credentials = new WebCredentials(username, password);

//        URI jira_url = URI.create("outlook.live.com");
        service.autodiscoverUrl(username, new RedirectionUrlCallback());
        service.setCredentials(credentials);

        FindFoldersResults findResults = service.findFolders(WellKnownFolderName.Inbox, new FolderView(Integer.MAX_VALUE));

        for (Folder folder : findResults.getFolders())
        {
            System.out.println("Count======" + folder.getChildFolderCount());
            System.out.println("Name=======" + folder.getDisplayName());
        }
    }

    static class RedirectionUrlCallback implements IAutodiscoverRedirectionUrl
    {
        @Override
        public boolean autodiscoverRedirectionUrlValidationCallback(
            String redirectionUrl)
        {
            return redirectionUrl.toLowerCase().startsWith("https://");
        }
    }

但我得到错误堆栈:

microsoft.exchange.webservices.data.autodiscover.exception.AutodiscoverLocalException: The Autodiscover service couldn't be located.
    at microsoft.exchange.webservices.data.autodiscover.AutodiscoverService.internalGetLegacyUserSettings(AutodiscoverService.java:742)

实现此代码的正确方法是什么?

【问题讨论】:

    标签: java outlook outlook-addin exchangewebservices ewsjavaapi


    【解决方案1】:

    获取房间资源日历的完整工作示例如下:Office365 API - Admin accessing another users/room's calendar events。您可以轻松调整代码以从经过身份验证的同一用户或其他用户/电子邮件/资源(如果您的经过身份验证的用户有权访问)获取日历事件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-18
      • 1970-01-01
      相关资源
      最近更新 更多