in the AttachmentsPropertyDefinition the version is checked using:
if (version != null
&& this.getVersion()
.compareTo(ExchangeVersion.Exchange2010_SP2) >= 0) {
but this getVersion() is fixed in the constructor as ExchangeVersion.Exchange2007_SP1. This will always be <0 as its comparing to constant values. I'm thinking it was meant to read as
if (version != null
&& version
.compareTo(ExchangeVersion.Exchange2010_SP2) >= 0) {
which would mean that the flags are set according to the requested exchange version.
This results in the attachments never being sent to the server on create item calls.
As a temporary workaround, the version in AttachmentsPropertyDefinition can be increased to 2010_SP2.
Field f= PropertyDefinition.class.getDeclaredField("version");
f.setAccessible(true);
f.set(ItemSchema.Attachments, ExchangeVersion.Exchange2010_SP2);
But the EWS API will fail the seemingly correct Exchange reponse:
This response
<?xml version="1.0" encoding="utf-8"?>
Caused by: microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException: Property type incompatible when updating collection.
at microsoft.exchange.webservices.data.property.complex.ComplexPropertyCollection.updateFromXml(ComplexPropertyCollection.java:189)
at microsoft.exchange.webservices.data.property.complex.ComplexProperty.updateFromXml(ComplexProperty.java:222)
at microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinitionBase.internalLoadFromXml(ComplexPropertyDefinitionBase.java:105)
at microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinitionBase.loadPropertyValueFromXml(ComplexPropertyDefinitionBase.java:150)
at microsoft.exchange.webservices.data.core.PropertyBag.loadFromXml(PropertyBag.java:510)
at microsoft.exchange.webservices.data.core.service.ServiceObject.loadFromXml(ServiceObject.java:298)
https://github.com/OfficeDev/ews-java-api/blob/33235f37d97871f17c496526aad0b8c458f904c3/src/main/java/microsoft/exchange/webservices/data/property/definition/AttachmentsPropertyDefinition.java#L69
in the AttachmentsPropertyDefinition the version is checked using: if (version != null && this.getVersion() .compareTo(ExchangeVersion.Exchange2010_SP2) >= 0) {
but this getVersion() is fixed in the constructor as ExchangeVersion.Exchange2007_SP1. This will always be <0 as its comparing to constant values. I'm thinking it was meant to read as if (version != null && version .compareTo(ExchangeVersion.Exchange2010_SP2) >= 0) {
which would mean that the flags are set according to the requested exchange version.
This results in the attachments never being sent to the server on create item calls.
As a temporary workaround, the version in AttachmentsPropertyDefinition can be increased to 2010_SP2.
But the EWS API will fail the seemingly correct Exchange reponse:
This response <?xml version="1.0" encoding="utf-8"?>
</s:Envelope>
will cause this error
Caused by: microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException: Property type incompatible when updating collection. at microsoft.exchange.webservices.data.property.complex.ComplexPropertyCollection.updateFromXml(ComplexPropertyCollection.java:189) at microsoft.exchange.webservices.data.property.complex.ComplexProperty.updateFromXml(ComplexProperty.java:222) at microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinitionBase.internalLoadFromXml(ComplexPropertyDefinitionBase.java:105) at microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinitionBase.loadPropertyValueFromXml(ComplexPropertyDefinitionBase.java:150) at microsoft.exchange.webservices.data.core.PropertyBag.loadFromXml(PropertyBag.java:510) at microsoft.exchange.webservices.data.core.service.ServiceObject.loadFromXml(ServiceObject.java:298)