title: How can I get / set an extended property from a contact using Microsoft's EWS API?
body: <p>I think I'm creating it properly, like as follows. c is a Contact, and I'm just trying to store a unique identifier considering that ItemId which is provided by EWS isnt static... </p>
  
  <pre><code>propertySetId = System.Guid.NewGuid();
  // Create a definition for the extended property.
  ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, "itemGUID", MapiPropertyType.String);
  c.SetExtendedProperty(extendedPropertyDefinition, propertySetId.ToString());
  c.Update(ConflictResolutionMode.AlwaysOverwrite);
  </code></pre>
  
  <p>When I try to pull this back out when searching for the contact based on something else, like first name, I'm getting a null returned. I'm trying to get the value by:</p>
  
  <pre><code>foreach (Item c in findResults.Items)
  {
        foreach(ExtendedProperty extendedProperty in c.ExtendedProperties)
        {
              if(extendedProperty.PropertyDefinition.Name == "itemGUID")
              {
                    results[i] = extendedProperty.Value.ToString();
              }
        }
  }
  </code></pre>
  
  <p>EDIT: code for findResults</p>
  
  <pre><code>List&lt;SearchFilter&gt; searchFilters = new List&lt;SearchFilter&gt;();
  searchFilters.Add(new SearchFilter.IsEqualTo(itemGUID, value));
  //can be more filters here depending on situation
  SearchFilter filter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, searchFilters.ToArray());
  findResults = service.FindItems(WellKnownFolderName.Contacts, filter, view);
  </code></pre>