gpt4 book ai didi

java - EWS : Unsupported restriction in FindItem request exception

转载 作者:行者123 更新时间:2023-12-01 09:41:47 25 4
gpt4 key购买 nike

我正在尝试实现Java客户端,它将使用EWS协议(protocol)与邮件服务器进行通信。所以我决定使用这个EWS API .

现在我尝试从邮箱获取项目,它运行良好,但是当我添加一些SearchFilter时,发生异常:

microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: Unsupported restriction in FindItem request
at microsoft.exchange.webservices.data.core.response.ServiceResponse.internalThrowIfNecessary(ServiceResponse.java:278)
at microsoft.exchange.webservices.data.core.response.ServiceResponse.throwIfNecessary(ServiceResponse.java:267)
at microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest.execute(MultiResponseServiceRequest.java:165)
at microsoft.exchange.webservices.data.core.ExchangeService.findItems(ExchangeService.java:985)
at microsoft.exchange.webservices.data.core.ExchangeService.findItems(ExchangeService.java:1028)
at microsoft.exchange.webservices.data.core.ExchangeService.findItems(ExchangeService.java:1088)
at main.Main.findItems(Main.java:66)
at main.Main.<init>(Main.java:49)
at main.Main.main(Main.java:84)

这是我使用过的代码,它是我从 Github 站点复制的代码:

public void findItems() throws Exception {
ItemView view = new ItemView(10);
view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending);
view.setPropertySet(new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, ItemSchema.DateTimeReceived));

SearchFilter filter1 = new SearchFilter.ContainsSubstring(ItemSchema.Subject, "EWS");
FindItemsResults<Item> findResults = service.findItems(WellKnownFolderName.Inbox, filter1, view);


//MOOOOOOST IMPORTANT: load items properties, before
service.loadPropertiesForItems(findResults, PropertySet.FirstClassProperties);
System.out.println("Total number of items found: " + findResults.getTotalCount());

for (Item item : findResults) {
System.out.println(item.getSubject());
System.out.println(item.getBody());
// Do something with the item.
}
}

谢谢

最佳答案

我找到了答案。

这是由电子邮件服务器引起的,该服务器不支持查找项目的限制。

关于java - EWS : Unsupported restriction in FindItem request exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38395980/

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