gpt4 book ai didi

java - ews-java-api 创建新约会

转载 作者:行者123 更新时间:2023-12-02 06:17:04 28 4
gpt4 key购买 nike

我想创建一个简单的 Java 程序,为我的 Outlook 日历创建一个新约会,但我不知道出了什么问题。

我也尝试发送一封简单的电子邮件,但它给出了相同的错误。

源代码:https://github.com/OfficeDev/ews-java-api/wiki/Getting-Started-Guide

public class test {
static class RedirectionUrlCallback implements IAutodiscoverRedirectionUrl {
public boolean autodiscoverRedirectionUrlValidationCallback(
String redirectionUrl) {
return redirectionUrl.toLowerCase().startsWith("https://");
}
}
public static void main(String[] args){
try {
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
ExchangeCredentials credentials = new WebCredentials("email@bc.ac.id", "password");
service.setCredentials(credentials);
service.autodiscoverUrl("email@bc.ac.id", new RedirectionUrlCallback());
Appointment appointment = new Appointment(service);
appointment.setSubject("Appointment for JAVA XML TEST");
appointment.setBody(MessageBody.getMessageBodyFromText("Test Body Msg in JAVA"));
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = formatter.parse("2019-04-16 12:00:00");
Date endDate = formatter.parse("2019-04-16 13:00:00");
appointment.setStart(startDate);//new Date(2010-1900,5-1,20,20,00));
appointment.setEnd(endDate); //new Date(2010-1900,5-1,20,21,00));
appointment.save();
}
catch (Exception e){
System.out.println(e);
}
}
}

错误代码:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/ws/http/HTTPException
at microsoft.exchange.webservices.data.core.ExchangeService.internalCreateItems(ExchangeService.java:593)
at microsoft.exchange.webservices.data.core.ExchangeService.createItem(ExchangeService.java:657)
at microsoft.exchange.webservices.data.core.service.item.Item.internalCreate(Item.java:245)
at microsoft.exchange.webservices.data.core.service.item.Item.save(Item.java:386)
at test.main(test.java:33)
Caused by: java.lang.ClassNotFoundException: javax.xml.ws.http.HTTPException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more

最佳答案

Eris Suryaputra,你为什么使用这么过时的东西?

此外,对于您和任何使用 EWS 的人来说,请注意,到 2020 年 10 月 13 日,Microsoft 预计所有使用依赖 Exchange Web Services 进行 Office 365 集成的第三方工具的管理员都将切换到 Microsoft Graph。同一天,EWS 中对基本身份验证的支持将完全停止,如您在 https://www.codementor.io/@anananet/using-java-to-integrate-with-microsoft-exchange-server-15h1qq0lzg 中看到的那样。 。

关于java - ews-java-api 创建新约会,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55863921/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com