使用Java API从Outlook.com获取日历事件 [英] Get calendar events from Outlook.com using Java API

查看:28
本文介绍了使用Java API从Outlook.com获取日历事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用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)

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

推荐答案

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

这篇关于使用Java API从Outlook.com获取日历事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆