InfiniTec - Henning Krauses Blog

Don't adjust your mind - it's reality that is malfunctioning

Setting the Task owner on new items using Exchange WebServices

If you try to set the owner of a task using Exchange WebServices, the server will tell you that this is not allowed. To circumvent this restriction, you’ll have to set the MAPI property directly. This is done by creating an ExtendedPropertyType instance and adding that to an UpdateItemType.

   1: var modification = new PathToExtendedFieldType
   2:     {
   3:         DistinguishedPropertySetId = DistinguishedPropertySetType.Task,
   4:         DistinguishedPropertySetIdSpecified = true,
   5:         PropertyId = 0x811f,
   6:         PropertyIdSpecified = true,
   7:         PropertyType = MapiPropertyTypeType.String
   8:     }, value);

However, this won’t work when creating new items. Exchange will return an error complaining about an invalid PropertySet id. The only solution I found is to issue a CreateItem request first. On this request, the task owner is omitted. After the item has been created, use the ItemId from the CreateItem response and execute an UpdateItem request setting only the task owner.

Posted by Henning Krause on Thursday, March 19, 2009 7:36 PM, last modified on Monday, November 29, 2010 9:31 PM
Permalink | Post RSSRSS comment feed