I need to search for a substring in a user's Calendar appointments. I don't have any other information about the appointment (GUID, Start Date, etc.). I just know that a particular substring is in the body.
I've read a couple articles on how to get the body of an appointment, but they search by the GUID or the subject. I'm trying to use the code below to search for a substring in the body, but I get an error that I can't use the Body in FindItems
.
Is there a way to do this? Assuming there's no way for me to get any other info from the appointment, is there another approach I can take?
//Variables
ItemView view = new ItemView(10);
view.PropertySet = new PropertySet(EmailMessageSchema.Body);
SearchFilter sfSearchFilter;
FindItemsResults<Item> findResults;
foreach (string s in substrings)
{
//Search for messages with body containing our permURL
sfSearchFilter = new SearchFilter.ContainsSubstring(EmailMessageSchema.Body, s);
findResults = service.FindItems(WellKnownFolderName.Calendar, sfSearchFilter, view);
if (findResults.TotalCount != 0)
{
Item appointment = findResults.FirstOrDefault();
appointment.SetExtendedProperty(extendedPropertyDefinition, s);
}