2
votes

Im doing an automatic process on a mailbox using EWS webservices and assigning ExtendedPropertyDefinition to the messages like this:

Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition extendedPropertyDefinition =
                           new Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, "Archivado", MapiPropertyType.String);

  msgComplete.SetExtendedProperty(extendedPropertyDefinition, iddoc);
                             msgComplete.Update(ConflictResolutionMode.AlwaysOverwrite);

On the other side, I am developing an Outlook Addin who needs to evaluate on every message click, if that message has this ExtendedPropertyDefinition name defined but I dont know how can I recover the Extended property from outlook addin using Outlook class.

I dont mind If I have to use another kind of properties to be accessible from both frameworks.

I have tried using the following properties in Outlook with no luck;

item.Userproperties;

item.PropertyAccesor.GetProperty("Archivado"); 

item.ItemProperties;
1

1 Answers

2
votes

Ok, finally I got it. I had to create the ExtendedPropertyDefinition using a Guid and recover it from outlook using the schema on the property like this:

//Setting the property with Exchange webservice:

string guid = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";

Guid MY_PROPERTY_SET_GUID = new Guid(guid); 

Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition extendedPropertyDefinition =
new Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(MY_PROPERTY_SET_GUID, "Archivado", MapiPropertyType.String);


//Recover the property using Outlook:


Outlook.MailItem item = (Outlook.MailItem)e.OutlookItem;

Outlook.UserProperties mailUserProperties = item.UserProperties;

dynamic property=item.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/string/{Outlook.MailItem item = (Outlook.MailItem)e.OutlookItem;

            Outlook.UserProperties mailUserProperties = item.UserProperties;
            dynamic property=item.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/string/{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}/Archivado");