I am developing C# .NET Framework 4.5 Windows Form application using EWS Managed API 1.2 with Exchange Server 2007 which performs some sort of syncing of mails.
Now that I am dealing with Extended Properties, I want to be clear some things:
Q1. What is the purpose of DefaultExtendedPropertySet
class? MSDN says "Defines the default sets of extended properties."
- Is it just to group the extended properties?
- If yes, why is the grouping there at first place?
- Do we have any Ews API method which can fetch values of all extended properties belonging to the same group on an item?
Q2. I am unable to decide whether should I use custom GUID or DefaultExtendedPropertySet.PublicStrings
while constructing ExtendedPropertyDefinition
:
var MyXProp = new ExtendedPropertyDefinition(
DefaultExtendedPropertySet.PublicStrings,
"MyXProp", MapiPropertyType.String);
OR
Guid MyPropertySetId = new Guid("{C11FF724-AA03-4555-9952-FA248A11C3E}");
var extendedPropertyDefinition = new ExtendedPropertyDefinition(
MyPropertySetId, "MyXProp", MapiPropertyType.String);
- What are the factors that should dictate the above decision?
- Also what difference it makes by above two approaches?
Immediate answers to my own questions are as below. But after reading I realized there are many more related things to know. So those things follows the answer.
Q1.
- Yes,
DefaultExtendedPropertySet
is for grouping purpose. Microsoft pre-defined some namespaces to encourage logical grouping of named properties and included them in this enumeration. - Grouping is in place for convinience and also to avoid collisions between names of different properties introduced by different vendors.
- No there is no API to fetch values of all properties belonging to same group.
Q2.
- GUID creates a new group thus providing separation at both levels, at group level and name level, However,
DefaultExtendedPropertySet.PublicStrings
with non-generic name is also sufficient. Point is to avoid collision with named property created by some other vendor.PublicStrings
can also provide better discoverability if the application is to be integrated with some other applications (GUIDs might need to be very carefully specified during itegration).
MAPI Properties
- Microsoft uses the Messaging API (MAPI) as a means to connect different messaging transport components. The MAPI specification represents most objects as properties identified by property identifiers or PropIDs.
- Property identifiers are a set of hexadecimal values that range from 1 to 0xFFFF (total 65536).
- Historically, for convinience, these properties are divided into logical groups.
- Standard MAPI properties or fixed properties - Properties below
0x8000
. This range is sub-divided into:- Transmittable - This range is made up of properties that Exchange can send with a message.
- Internal - This range is made up of properties that may be set only by Exchange.
- Non transmittable - This range represents properties that are not delivered outside the organization when Exchange delivers a message
- Named Properties - properties above
0x8000
. They allow vendors/developers to extend the standard MAPI property set by adding their own properties. There are two flavors of named properties:- Properties with numeric names - used by programs such as MS Outlook; these property names are generally defined in a source file.
- Properties with string names - these properties have GUIDs associated with them along with names, thus allowing developers to divide named properties into property sets.Every GUID represents a property set, thus all named properties with same GUID associated with them belongs to the same property set.
rfc822 x-headers to MAPI properties conversion
- Messages sent on the Internet are sent in the format message/rfc822 which has support for set of properties called x-headers.
- Conversion from rfc822 x-headers key-value pair to MAPI properties is done by a component called Imail.
- Thus if an in-bound message has x-header, Imail will create named property for it and store it on the message.
There are some subtle historical details such as
- Imail was re-written in Exchange 2000 to include Ad-hoc headers which in turn included x-headers.
- Since there is a limitation on number (65536) of MAPI-properties, quotas are assigned to them on Exchange server
- From versions to versions of Exchange server following things are changed due to different design decisions:
- where MAPI properties will be maintained like on a particular mail or across whole mailbox database
- rules to reserve GUID and a name to a MAPI property
Read in more details at below links:
- http://technet.microsoft.com/en-us/library/bb851492(v=exchg.80).aspx
- http://technet.microsoft.com/en-us/library/jj937955(v=exchg.141).aspx
- http://technet.microsoft.com/en-us/library/bb851493(v=exchg.80).aspx
- http://blogs.technet.com/b/exchange/archive/2010/07/29/3410545.aspx
- http://blogs.technet.com/b/exchange/archive/2009/04/06/3407221.aspx
Q1) The DefaultExtendedPropertySet
enumeration defines the default extended property sets that Exchange has, such as the DefaultExtendedPropertySet.Task
. It is not meant to be used for your own custom extended property set.
Q2) MSDN is quite explicit about using a Guid for any custom extended property set, so I would indeed do so. Within that property set, you can of course use any name for your property.
来源:https://stackoverflow.com/questions/25187481/should-i-use-guid-or-defaultextendedpropertyset-publicstrings-while-constructing