I'm using the EWS API in C# with an onsite Exchange 2007 SP1 Server. I'm using the following code to tag a message using a custom property definition.
//Bind to the message in question, which works fine. Item m = Item.Bind(service, new ItemId(itemid)); //Define the extended property definition. ExtendedPropertyDefinition def = new ExtendedPropertyDefinition(MyGUID, "my-tag-name" MapiPropertyType.String); //Set the extended property to our tag which is a string m.SetExtendedProperty(def, tag); //Starting tracing, see XML snippet below. service.TraceEnabled = true; //Update the message with our new tag. i.Update(ConflictResolutionMode.AlwaysOverwrite);
The issue is the server is throwing "Internal Server Errors' in response as shown in the trace below. Its not a general issue with credentials/autodiscover as I'm able to bind to messages and retrieve information about them without an issue.
Does anyone have any ideas?
<Trace Tag="EwsRequestHttpHeaders" Tid="1" Time="2014-03-03 12:52:49Z"> POST /EWS/Exchange.asmx HTTP/1.1 Content-Type: text/xml; charset=utf-8 Accept: text/xml User-Agent: ExchangeServicesClient/15.00.0516.014 Accept-Encoding: gzip,deflate</Trace><Trace Tag="EwsRequest" Tid="1" Time="2014-03-03 12:52:49Z" Version="15.00.0516. 014"><?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m=" http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://sc hemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xml soap.org/soap/envelope/"><soap:Header><t:RequestServerVersion Version="Exchange2007_SP1" /><t:TimeZoneContext><t:TimeZoneDefinition Id="GMT Standard Time" /></t:TimeZoneContext></soap:Header><soap:Body><m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOver write"><m:ItemChanges><t:ItemChange><t:ItemId Id="<<Removed>>=" ChangeKey="<<Removed>>" /><t:Updates><t:SetItemField><t:ExtendedFieldURI PropertySetId="2b3c76fb-2ea6-4644-a9d1-ae5b5 8b4396b" PropertyName="mytag" PropertyType="String" /><t:Message><t:ExtendedProperty><t:ExtendedFieldURI PropertySetId="2b3c76fb-2ea6-4644-a9d1-a e5b58b4396b" PropertyName="mytag" PropertyType="String" /><t:Value>tagvalue</t:Value></t:ExtendedProperty></t:Message></t:SetItemField></t:Updates></t:ItemChange></m:ItemChanges></m:UpdateItem></soap:Body></soap:Envelope></Trace><Trace Tag="EwsResponseHttpHeaders" Tid="1" Time="2014-03-03 12:52:49Z"> HTTP/1.1 200 OK Content-Encoding: gzip Vary: Accept-Encoding Content-Length: 551 Cache-Control: private, max-age=0 Content-Type: text/xml; charset=utf-8 Date: Mon, 03 Mar 2014 12:52:49 GMT Server: Microsoft-IIS/7.0 X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET</Trace><Trace Tag="EwsResponse" Tid="1" Time="2014-03-03 12:52:49Z" Version="15.00.0516 .014"><?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs i="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/ XMLSchema"><soap:Header><t:ServerVersionInfo MajorVersion="8" MinorVersion="1" MajorBuildNumber="4 36" MinorBuildNumber="0" Version="Exchange2007_SP1" xmlns:t="http://schemas.micr osoft.com/exchange/services/2006/types" /></soap:Header><soap:Body><m:UpdateItemResponse xmlns:t="http://schemas.microsoft.com/exchange/servi ces/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/mes sages"><m:ResponseMessages><m:UpdateItemResponseMessage ResponseClass="Error"><m:MessageText>An internal server error occurred. The operation fail ed.</m:MessageText><m:ResponseCode>ErrorInternalServerError</m:ResponseCode><m:DescriptiveLinkKey>0</m:DescriptiveLinkKey><m:Items /></m:UpdateItemResponseMessage></m:ResponseMessages></m:UpdateItemResponse></soap:Body></soap:Envelope></Trace>