C# EWS搜索子字符串的约会正文
我需要在用户的日历约会中搜索子字符串。我没有关于约会的任何其他信息(GUID、开始日期等)。我只知道身体里有一个特殊的子串 我读过几篇关于如何获取约会正文的文章,但它们是按GUID或主题搜索的。我试图使用下面的代码在正文中搜索子字符串,但我得到一个错误,即我无法在C# EWS搜索子字符串的约会正文,c#,calendar,exchangewebservices,appointment,C#,Calendar,Exchangewebservices,Appointment,我需要在用户的日历约会中搜索子字符串。我没有关于约会的任何其他信息(GUID、开始日期等)。我只知道身体里有一个特殊的子串 我读过几篇关于如何获取约会正文的文章,但它们是按GUID或主题搜索的。我试图使用下面的代码在正文中搜索子字符串,但我得到一个错误,即我无法在FindItems中使用正文 有办法做到这一点吗?假设我无法从约会中获得任何其他信息,我可以采取其他方法吗 //Variables ItemView view = new ItemView(10);
FindItems
中使用正文
有办法做到这一点吗?假设我无法从约会中获得任何其他信息,我可以采取其他方法吗
//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);
}
//变量
ItemView视图=新的ItemView(10);
view.PropertySet=newpropertyset(EmailMessageSchema.Body);
搜索过滤器;
FindItemsResults findResults;
foreach(子字符串中的字符串s)
{
//搜索正文中包含我们的永久URL的邮件
sfSearchFilter=newsearchfilter.ContainsSubstring(EmailMessageSchema.Body,s);
findResults=service.FindItems(WellKnownFolderName.Calendar、sfSearchFilter、view);
如果(findResults.TotalCount!=0)
{
Item appointment=findResults.FirstOrDefault();
任命。SetExtendedProperty(extendedPropertyDefinition,s);
}
因此,您可以搜索正文,但不能返回带有FindItems
的正文。如果您想使用它,您必须稍后加载它。因此,我没有将我的属性集设置为正文,而是将其设置为I仅
,然后设置搜索过滤器
,以遍历项目架构的正文>
//Return one result--there should only be one in this case
ItemView view = new ItemView(1);
view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
//variables
SearchFilter sfSearchFilter;
FindItemsResults<Item> findResults;
//for each string in list
foreach (string s in permURLs)
{
//Search ItemSchema.Body for the string
sfSearchFilter = new SearchFilter.ContainsSubstring(ItemSchema.Body, s);
findResults = service.FindItems(WellKnownFolderName.Calendar, sfSearchFilter, view);
if (findResults.TotalCount != 0)
{
Item appointment = findResults.FirstOrDefault();
appointment.SetExtendedProperty(extendedPropertyDefinition, s);
...
appointment.Load(new PropertySet(ItemSchema.Body));
string strBody = appointment.Body.Text;
}
}
//返回一个结果——在这种情况下应该只有一个结果
ItemView视图=新的ItemView(1);
view.PropertySet=newpropertyset(BasePropertySet.IdOnly);
//变数
搜索过滤器;
FindItemsResults findResults;
//对于列表中的每个字符串
foreach(permURL中的字符串s)
{
//在ItemSchema.Body中搜索字符串
sfSearchFilter=newsearchfilter.ContainsSubstring(ItemSchema.Body,s);
findResults=service.FindItems(WellKnownFolderName.Calendar、sfSearchFilter、view);
如果(findResults.TotalCount!=0)
{
Item appointment=findResults.FirstOrDefault();
任命。SetExtendedProperty(extendedPropertyDefinition,s);
...
Load(新属性集(ItemSchema.Body));
字符串strBody=appointment.Body.Text;
}
}