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:
classMyClass{privatestaticGuid isProcessedPropertySetId;privatestaticExtendedPropertyDefinition isProcessedPropertyDefinition =null;staticMyClass(){
isProcessedPropertySetId =newGuid("{20F3C09F-7CAD-44c6-BDBF-8FCB324244}");
isProcessedPropertyDefinition =newExtendedPropertyDefinition(isProcessedPropertySetId,"IsItemProcessed",MapiPropertyType.String);}publicList<EmailMessage> getAllMailsInInbox(){List<EmailMessage> emails =newList<EmailMessage>();ItemView itemView =newItemView(100,0);FindItemsResults<Item> itemResults =null;PropertySet psPropSet =newPropertySet(BasePropertySet.IdOnly);
itemView.PropertySet= psPropSet;PropertySet itItemPropSet =newPropertySet(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?