locked
Exchange extended attributes as well as getting a message body RRS feed

  • Question

  • Hi, I am using the following code in C# currently to get firstcalss properties as well one extended property. I am trying to read public folder mail messages to report the statistics. I have used mfcmapi to find out the name of this extended property as "0x802E001E". I have listed below the tag, type,dasl, named prop name and its guid. I have tried using the tag, named prop name as 0x8530 and also 34096 and dispidRequest.

    Tag: 0x802E001E
    Type: PT_STRING8
    DASL: link here

    Named Prop Name: id: 0x8530=34096 = PidLidFlagRequest, dispidRequest
    Named Prop Guid: {00062008-0000-0000-C000-000000000046} = PSETID_Common

    This has always showed me the extendedproperties count as 0. And also it is not able to get the body text. this is the following error message I get inspite of changing the exchange version to all the available options like Exchange2007_sp1, exchange2010, exchange2010_sp1 and sp2.  

    'item.TextBody' threw an exception of type 'Microsoft.Exchange.WebServices.Data.ServiceVersionException'

    Could someone suggest me a solution to get these properties?

    Thanks.

    var  staffFlag = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "0x802E001E", MapiPropertyType.String);
    ExtendedPropertyDefinition[] extendedFields = new ExtendedPropertyDefinition[] { staffFlag };
    PropertySet extendedPropertySet = new PropertySet(BasePropertySet.FirstClassProperties, extendedFields);
    ItemView itemView = new ItemView(1000) { PropertySet = extendedPropertySet };
    FindItemsResults<Item> findResults;
    do

    {

    findResults = fl.FindItems(itemView);
    foreach (Item item in findResults.Items)
    {
    if (item.ExtendedProperties.Count > 0)
    {
    foreach (ExtendedProperty extendedProperty in item.ExtendedProperties)
    {
    Console.WriteLine(" Extended Property Name: " + extendedProperty.PropertyDefinition.Name);
    Console.WriteLine(" Extended Property Value: " + extendedProperty.Value);
    }

    }

    }

    itemView.Offset += 1000;

    }
    while (findResults.MoreAvailable);

    Thursday, October 3, 2013 12:09 PM

Answers

  • Thank you Very much Glen. Much appreciated.
    • Marked as answer by skeerthi123 Friday, October 4, 2013 12:09 PM
    Friday, October 4, 2013 12:09 PM

All replies

  • The body of Message wont be returned in a FindItems Request you will need to either use a Load (which makes a GetItem request) or use LoadPropertiesFromItems (which does a batch GetItem)  see http://blogs.msdn.com/b/exchangedev/archive/2010/03/16/loading-properties-for-multiple-items-with-one-call-to-exchange-web-services.aspx

    In your property request your using the wrong DefaultExtendedPropertySet this is LCID value so you need to use the PropTag (minus the last 4 digits which is the property type) as an Integer (or hex). Using it as a String like you are won't work and is only used from String Named Properties. eg something like this should work

                var staffFlag = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Common, 0x8530, MapiPropertyType.String);
                PropertySet extendedPropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
                extendedPropertySet.Add(staffFlag);
                ItemView itemView = new ItemView(1000) { PropertySet = extendedPropertySet };
                FindItemsResults<Item> findResults;
                do
                {
    
                    findResults = fl.FindItems(itemView);                
                    foreach (Item item in findResults.Items)
                    {
                        Object FlagVal = null;
                        if(item.TryGetProperty(staffFlag,out FlagVal)){
                            Console.WriteLine(FlagVal);
                        }
                    }
    
                    itemView.Offset += findResults.Items.Count;
    
                }
                while (findResults.MoreAvailable);
    Cheers
    Glen


    Friday, October 4, 2013 2:51 AM
  • Thank you Very much Glen. Much appreciated.
    • Marked as answer by skeerthi123 Friday, October 4, 2013 12:09 PM
    Friday, October 4, 2013 12:09 PM