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

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?


March 6th, 2014 7:30am

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

Free Windows Admin Tool Kit Click here and download it now
March 6th, 2014 11:22pm

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

March 7th, 2014 7:15am

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

Free Windows Admin Tool Kit Click here and download it now
March 7th, 2014 7:15am

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

March 7th, 2014 7:15am

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?
Free Windows Admin Tool Kit Click here and download it now
March 8th, 2014 6:01am

>>  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

March 9th, 2014 11:42pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics