I have a Windows Service written in C# that polls an Exchange server to process mails to an unattended email box.
It's been working fine, until today when it's throwing up the following error:-
EXCEPTION: Microsoft.Exchange.WebServices.Data.ServiceVersionException: The property Hashtags is valid only for Exchange Exchange2015 or later versions.
at Microsoft.Exchange.WebServices.Data.PropertyBag.set_Item(PropertyDefinition propertyDefinition, Object value)
at Microsoft.Exchange.WebServices.Data.ComplexPropertyDefinitionBase.InternalLoadFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
at Microsoft.Exchange.WebServices.Data.ComplexPropertyDefinitionBase.LoadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
at Microsoft.Exchange.WebServices.Data.PropertyBag.LoadFromXml(EwsServiceXmlReader reader, Boolean clear, PropertySet requestedPropertySet, Boolean onlySummaryPropertiesRequested)
at Microsoft.Exchange.WebServices.Data.ServiceObject.LoadFromXml(EwsServiceXmlReader reader, Boolean clearPropertyBag, PropertySet requestedPropertySet, Boolean summaryPropertiesOnly)
at Microsoft.Exchange.WebServices.Data.EwsServiceXmlReader.ReadServiceObjectsCollectionFromXml[TServiceObject](XmlNamespace collectionXmlNamespace, String collectionXmlElementName, GetObjectInstanceDelegate`1 getObjectInstanceDelegate, Boolean clearPropertyBag, PropertySet requestedPropertySet, Boolean summaryPropertiesOnly)
at Microsoft.Exchange.WebServices.Data.EwsServiceXmlReader.ReadServiceObjectsCollectionFromXml[TServiceObject](String collectionXmlElementName, GetObjectInstanceDelegate`1 getObjectInstanceDelegate, Boolean clearPropertyBag, PropertySet requestedPropertySet, Boolean summaryPropertiesOnly)
at Microsoft.Exchange.WebServices.Data.GetItemResponse.ReadElementsFromXml(EwsServiceXmlReader reader)
at Microsoft.Exchange.WebServices.Data.ServiceResponse.LoadFromXml(EwsServiceXmlReader reader, String xmlElementName)
at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.ParseResponse(EwsServiceXmlReader reader)
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ParseResponse(EwsServiceXmlReader reader, WebHeaderCollection responseHeaders)
at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ReadResponse(EwsServiceXmlReader ewsXmlReader, WebHeaderCollection responseHeaders)
at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponseXml(Stream responseStream, WebHeaderCollection responseHeaders)
at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.ReadResponse(IEwsHttpWebResponse response)
at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute()
at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalLoadPropertiesForItems(IEnumerable`1 items, PropertySet propertySet, ServiceErrorHandling errorHandling)
at Microsoft.Exchange.WebServices.Data.ExchangeService.LoadPropertiesForItems(IEnumerable`1 items, PropertySet propertySet)
at MyServiceName.MyServiceName.CheckForNewEmails(ExchangeService service) in C:\TFSOnline\RPM Tools\MyServiceName\MyServiceName\MyServiceName.cs:line 177
at MyServiceName.MyServiceName.RunACheck(Object state) in C:\TFSOnline\RPM Tools\MyServiceName\MyServiceName\MyServiceName.cs:line 117
The line causing the crash is:
PropertySet properties = (BasePropertySet.FirstClassProperties);
service.LoadPropertiesForItems(emails, properties);
The specific error is:
Microsoft.Exchange.WebServices.Data.ServiceVersionException:
The property Hashtags is valid only for Exchange Exchange2015 or later versions.
I'm not using or accessing Hashtags anywhere, so presumably it's contained in BasePropertySet.FirstClassProperties.
As I mentioned, I've been using the above code quite happily up to now, it's only started giving this error today.
I'm using the latest EWS Stable Build: Exchange.WebServices.Managed.Api 2.2.1.1
BasePropertySet only has one other item, IdOnly, and the property I'm after is InternetMessageId, so I figured I'd just use that:
PropertySet properties = (BasePropertySet.IdOnly);
service.LoadPropertiesForItems(emails, properties);
Turns out InternetMessageId isn't covered by the property to get IDs...
EXCEPTION: Microsoft.Exchange.WebServices.Data.ServiceObjectPropertyException:
You must load or assign this property before you can read its value.
at Microsoft.Exchange.WebServices.Data.PropertyBag.get_Item(PropertyDefinition propertyDefinition)
at Microsoft.Exchange.WebServices.Data.EmailMessage.get_InternetMessageId()
The section of code giving the error hasn't changed, and as far as I can tell there's been no update to Office 365 that's affected Exchange.
To double-check, I took a previous version (compiled code, not source code that I recompiled) and installed that instead: still got the same error.
Anyone had this error before? I've Googled it but didn't get a single hit.
Edit: Tried installing the service on another machine on the off-chance it was specific to the machine it had been on.
Still get the same error, even with the previous code.