none
Unable to fetch built in properties of email along with the extended property using EWS Managed API RRS feed

  • Question

  • I am working with Exchange Web Services Managed API. I am adding a single extended property to mail items in inbox as they get processed based on some condition. Thus, not all mails will get this extended property attached to them.

    Next I am refetching all mails in inbox and if they have this property attached to them, I process them again.

    Below is the simple method getAllMailsInInbox(), I have written to refetch the mails in inbox:

    class MyClass
    {
        private static Guid isProcessedPropertySetId;
        private static ExtendedPropertyDefinition isProcessedPropertyDefinition = null;
    
        static MyClass()
        {
            isProcessedPropertySetId = new Guid("{20F3C09F-7CAD-44c6-BDBF-8FCB324244}");
            isProcessedPropertyDefinition = new  ExtendedPropertyDefinition(isProcessedPropertySetId, "IsItemProcessed", MapiPropertyType.String);
        }
    
        public List<EmailMessage> getAllMailsInInbox()
        {
            List<EmailMessage> emails = new List<EmailMessage>();
            ItemView itemView = new ItemView(100, 0);
            FindItemsResults<Item> itemResults = null;
    
            PropertySet psPropSet = new PropertySet(BasePropertySet.IdOnly);
            itemView.PropertySet = psPropSet;
    
            PropertySet itItemPropSet = new PropertySet(BasePropertySet.IdOnly,                                             
                                              ItemSchema.Attachments,
                                              ItemSchema.Subject,                                               
                                              ItemSchema.Importance,
                                              ItemSchema.DateTimeReceived,
                                              ItemSchema.DateTimeSent,
                                              ItemSchema.ItemClass,
                                              ItemSchema.Size,
                                              ItemSchema.Sensitivity,
                                              EmailMessageSchema.From,
                                              EmailMessageSchema.CcRecipients,
                                              EmailMessageSchema.ToRecipients,       
                                              EmailMessageSchema.InternetMessageId,                                                              
                                              ItemSchema.MimeContent,
                                              isProcessedPropertyDefinition);   //***
    
             itemResults = service.FindItems(WellKnownFolderName.Inbox, itemView); 
             service.LoadPropertiesForItems(itemResults.Items, itItemPropSet);
    
             String subject = itItem.Subject; //Exception: "You must load or assign this property before you can read its value."
             //....
        }
    }

    As you can see, on call service.LoadPropertiesForItems(), it does not load any properties, thus resulting in You must load or assign this property before you can read its value.exception while accessing any of those properties.

    If I remove isProcessedPropertyDefinition from the itItemPropSet property set, it fetches all the properties properly.

    So can I just know how can I fetch all built in EmailMessage properties along with the extended property?


    Thursday, March 6, 2014 12:23 PM

Answers

  • Your GUID isn't valid a valid GUID needs 34 digits yours has 32 (your missing 2 digits in the last block).

    I would suggest you don't use your own guid and just use the Standard DefaultExtendedPropertySet.PublicStrings.

    Cheers
    Glen

    Friday, March 7, 2014 4:15 AM

All replies

  • Your GUID isn't valid a valid GUID needs 34 digits yours has 32 (your missing 2 digits in the last block).

    I would suggest you don't use your own guid and just use the Standard DefaultExtendedPropertySet.PublicStrings.

    Cheers
    Glen

    Friday, March 7, 2014 4:15 AM
  • Hey sorry glen, I miss-manipulated that GUID while forming the question. It has 34 digits in my code. I think this has more to do with failure of our Exchange server instance to deal with the extended properties themselves as I specified in this question on MSDN. Is it like that? Can you please confirm this is related to the something wrong with our Exchange server? We have Exchange Server 2007 SP1. Also weird to notice, though we have EWS Managed API 2.0 installed and we reference its DLLs in our app, we cannot find this overload of Delete in Intellisense. Is this API mismatch?
    Saturday, March 8, 2014 10:53 AM
  • >>  We have Exchange Server 2007 SP1

    What version of Service Pack and Rollup is your server at ? the latest release that contains all the Fixes is Service Pack 3 rollup 12. If your not at this level you (and you don't have a development environment) you might want to try and build a virtualized dev environment and install the same patch level you have in production to see if you can reproduce the error in a different environment. Then try upgrading this dev environment to see if it solves the problem.

    >>Also weird to notice, though we have EWS Managed API 2.0 installed and we reference its DLLs in our app, we cannot find this overload of Delete in Intellisense. Is this API mismatch?

    The ability to supress read recipients isn't available on 2007 or 2010 from DeleteItem see http://msdn.microsoft.com/en-us/library/aa562961(v=exchg.80).aspx . (You would need to do it by setting the Extended Mapi properties directly using UpdateItems before the delete). Also I believe it was only added to the Managed API in 2.1 which was released a few weeks ago.

    Cheers
    Glen

    Monday, March 10, 2014 3:35 AM