locked
EWS Managed API: Extended Properties 101 RRS feed

  • General discussion

  • When working with EWS, you often need to read and/or write what we call Extended Properties. With Extended Properties, you can set properties that are otherwise read-only if you know their MAPI property tag (but you do that at your won risks - there is a reason why properties are read-only!). You can also stamp your items with your own custom properties. The below example shows how to set, read and remove the ConversationTopic property via Extended Properties:

    class TestProgram
    {
        public static ExtendedPropertyDefinition ConversationTopic = new ExtendedPropertyDefinition(0x0070, MapiPropertyType.String);
    
        static void Main(string[] args)
        {
            ExchangeService service = new ExchangeService();
            // Set service.Credentials or service.UseDefaultCredentials to true
            // Set service.Url or call service.AutodiscoverUrl
    
            // The following creates a message with the ConversationTopic property set
            EmailMessage message = new EmailMessage(service);
            message.Subject = "Draft message with custom property";
            message.SetExtendedProperty(TestProgram.ConversationTopic, "My topic");
            message.Save();
    
            // The following reads the ConversationTopic property of the message:
            string conversationTopic = (string)message[TestProgram.ConversationTopic];
    
            // The following removes the ConversationTopic property from the message: 
            message.RemoveExtendedProperty(TestProgram.ConversationTopic);
            message.Update(ConflictResolutionMode.AutoResolve);
    
            Console.ReadLine();
        }
    }
    

    David Claux | Program Manager - Exchange Web Services
    Sunday, April 19, 2009 6:25 PM

All replies

  • How can you read this using not managed EWS, but just EWS?
    Wednesday, May 13, 2009 2:53 PM
  • How can you read this using not managed EWS, but just EWS?
    Wednesday, May 13, 2009 2:53 PM
  • How to read extended properties that are available in EWS like this?
    1. PathToExtendedFieldType _propertyX = new PathToExtendedFieldType();
    2. _propertyX.DistinguishedPropertySetId = DistinguishedPropertySetType.PublicStrings;
    3. _propertyX.DistinguishedPropertySetIdSpecified = true;
    4. _propertyX.PropertyName = "urn:schemas:contacts:propertyx";
    5. _propertyX.PropertyType = MapiPropertyTypeType.String;

    Thursday, July 9, 2009 1:27 PM
  • ExtendedPropertyDefinition myProperty = new ExtendedPropertyDefinition(
        DefaultExtendedPropertySet.PublicStrings,
        "urn:schemas:contacts:propertyx",
        MapiPropertyType.String);
    
    Item item = Item.Bind(
        service,
        new ItemId("your id"),
        new PropertySet(BasePropertySet.FirstClassProperties, myProperty));
    

    David Claux | Program Manager - Exchange Web Services
    Thursday, July 9, 2009 6:51 PM
  • ExtendedPropertyDefinition myProperty = new
     ExtendedPropertyDefinition(
        DefaultExtendedPropertySet.PublicStrings,
        "urn:schemas:contacts:propertyx"
    ,
        MapiPropertyType.String);
    
    Item item = Item.Bind(
        service,
        new
     ItemId("your id"
    ),
        new
     PropertySet(BasePropertySet.FirstClassProperties, myProperty));
    
    

    David Claux | Program Manager - Exchange Web Services
    Hi,

    maybe you can help me with a sample for this.

    I tried to get the Extended Property for the VotingResponse. The message that I use for testing is the reply to a vote which was "Approved". So the subject is now "APPROVE: old subject"

                        ExtendedPropertyDefinition myProperty = new ExtendedPropertyDefinition(
                            DefaultExtendedPropertySet.PublicStrings,
                            "urn:schemas-microsoft-com:xml-msdata:VotingResponse",
                            MapiPropertyType.String);

                            Item item = Item.Bind(
                                es,
                                message.Id,
                                new PropertySet(BasePropertySet.FirstClassProperties, myProperty));


    The item object does not have any extended property available after the call. Am I doing anything wrong?

    Any help would be apreciated

    Thanks in advance...
    Friday, July 10, 2009 11:30 AM
  • Thanks!
    Monday, July 13, 2009 11:30 AM