ews-java-api:项目更新错误:至少一个收件人无效

Posted

技术标签:

【中文标题】ews-java-api:项目更新错误:至少一个收件人无效【英文标题】:ews-java-api: Error on item update: At least one recipient isn't valid 【发布时间】:2016-06-27 12:09:40 【问题描述】:

我正在开发一个工具,它使用 ews-java-api 在 Outlook 议程中创建、更新和删除日历项目。它一直工作正常,但现在有时当它尝试更新某些日历项目时,我收到以下错误:

microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: At least one recipient isn't valid., A message can't be sent because it contains no recipients.
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.internalUpdateItems(ExchangeService.java:691)
at microsoft.exchange.webservices.data.core.ExchangeService.updateItem(ExchangeService.java:762)
at microsoft.exchange.webservices.data.core.service.item.Item.internalUpdate(Item.java:279)
at microsoft.exchange.webservices.data.core.service.item.Item.update(Item.java:400)
at be.vrt.quintiqexchange.main.QuintiqAdapter.insertUpdateCalendarItems(QuintiqAdapter.java:879)
at be.vrt.quintiqexchange.main.QuintiqAdapter.updateCalendarItems(QuintiqAdapter.java:796)
at be.vrt.quintiqexchange.main.QuintiqAdapter.run(QuintiqAdapter.java:286)
at java.lang.Thread.run(Thread.java:745)

近期所有exchange账户都从本地Outlook服务器迁移到Office365云服务器。也许这与它有关?或者有人知道出了什么问题吗?

以下代码是对一个项目执行更新:

Item it = alitems.get(i);
...
it.update(ConflictResolutionMode.AlwaysOverwrite);

以下是用来访问office365 ews的url:

exchangewebservice = https://outlook.office365.com/EWS/Exchange.asmx

提前致谢

编辑:我使用的是 ews-java-api 2.0 版

编辑:在这里您可以看到错误发生在一行而不是下一行,对于相同的收件人,它不会发生...

microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException: At least one recipient isn't valid., A message can't be sent because it contains no recipients.
    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.internalUpdateItems(ExchangeService.java:691)
    at microsoft.exchange.webservices.data.core.ExchangeService.updateItem(ExchangeService.java:762)
    at microsoft.exchange.webservices.data.core.service.item.Item.internalUpdate(Item.java:279)
    at microsoft.exchange.webservices.data.core.service.item.Item.update(Item.java:400)
    at be.vrt.quintiqexchange.main.QuintiqAdapter.insertUpdateCalendarItems(QuintiqAdapter.java:880)
    at be.vrt.quintiqexchange.main.QuintiqAdapter.updateCalendarItems(QuintiqAdapter.java:703)
    at be.vrt.quintiqexchange.main.QuintiqAdapter.run(QuintiqAdapter.java:283)
    at java.lang.Thread.run(Thread.java:745)
WARN  be.vrt.quintiqexchange.main.QuintiqAdapter - At least one recipient isn't valid., A message can't be sent because it contains no recipients.by UPDATE for subject:  on Thu Jun 23 14:00:00 CEST 2016 Thu Jun 23 19:00:00 CEST 2016 of user name.lastname@domain.com
INFO  be.vrt.quintiqexchange.main.QuintiqAdapter - Appointment updated for subject: NIET DAG on Fri Aug 05 10:00:00 CEST 2016 Fri Aug 05 18:00:00 CEST 2016 of user name.lastname@domain.com
INFO  be.vrt.quintiqexchange.main.QuintiqAdapter - Appointment updated for subject: PROEF st5 on Mon Aug 22 10:00:00 CEST 2016 Mon Aug 22 20:30:00 CEST 2016 of user name.lastname@domain.com

这意味着收件人并不是真正的问题,我猜...

附言我替换了原来的邮件地址,但相信我,这是一个正确的邮件地址 :)

【问题讨论】:

我对 Java 和 EWS 一无所知,但如果您查看UpdateItem documentation,您会发现还有一个 MessageDisposition。您没有指定任何内容。也许这是试图向不存在的用户发送通知... 您好,谢谢您的回复。嗯,ews-java-api 中的更新方法将 MessageDisposition 设置为 SaveOnly。它还将 SendInvitationsOrCancellationsMode 设置为 null。在 c# 中有一个重载方法,您可以在其中设置 SendInvitationsOrCancellationsMode,但在 Java 中则不行... 我认为你需要设置有效的收件人@MaartenMeeusen 是的,就是这么说的,就是这样。它已经工作了很长时间,突然它随机开始给我这些错误。但是收件人地址没有改变..它也可以与一个收件人一起工作,然后在同一收件人不再工作1分钟后..这就是为什么它如此奇怪...... 【参考方案1】:

在我的例子中,如果地址没有被正确修剪并且有任何空白字符,EWS 会抛出这个异常。

【讨论】:

以上是关于ews-java-api:项目更新错误:至少一个收件人无效的主要内容,如果未能解决你的问题,请参考以下文章

Ajax异步表单简单实现收索功能

SoapUI中读取Office365邮件

Access VBA:查询输入必须至少包含一个表或查询

Typescript入门手册类型收窄(Narrowing)

Typescript入门手册类型收窄(Narrowing)

Typescript入门手册类型收窄(Narrowing)