在我之前使用 EWS 的项目中,我的搜索条件要简单得多:查找主题中带有“xxx”的电子邮件。
我现在正在将此代码构建到一个更具多功能性的应用程序中;我将监视各种邮箱的各种标准,例如:
查找收件人为“[电子邮件受保护]”,并且主题包含“xxx”并且(正文包含“yyy”或正文包含“zzz”)
但是,使用 SearchFilterCollection,虽然我可以添加多个 SearchFilter,但我不知道如何应用不同的逻辑运算符...每个似乎都有一个逻辑运算符SearchFilterCollection:
SearchFilterCollection sfc = new SearchFilterCollection(LogicalOperator.Or, new SearchFilter.ContainsSubstring(ItemSchema.Subject, "Test"));
我想一个解决方案是找到所需邮件项目的超集,然后在处理邮件时更准确地过滤它们。但我想知道是否有更好的方法在开始时进行过滤,使用 SearchFilters 或任何其他方式?
In a previous project where I used EWS, my search criteria was much simpler: find emails with "xxx" in the Subject.
I'm now building this code into a more multi-purpose application; I will be monitoring various mailboxes for various criteria, for example:
Find all mail items where the recipient is "[email protected]", AND subject contains "xxx" AND (body contains "yyy" OR body contains "zzz")
However, using a SearchFilterCollection, although I can add multiple SearchFilters, I don't see how to apply different logical operators... there seems to be one logical operator per SearchFilterCollection:
SearchFilterCollection sfc = new SearchFilterCollection(LogicalOperator.Or, new SearchFilter.ContainsSubstring(ItemSchema.Subject, "Test"));
I suppose one solution would be to find a superset of the desired mail items, and then filter them more accurately later, when they are being processed. But I was wondering if there is a better way of filtering at the start, using SearchFilters or any other means?
发布评论
评论(1)
您可以使用
SearchFilter.SearchFilterCollection (LogicalOperator, SearchFilter[])
构建复杂的搜索过滤器检查:如何:在 EWS 托管 API 1.0 中使用 SearchFilter 和 SearchFilterCollection 构建复杂搜索
You could build-up your complex Searchfilter using
SearchFilter.SearchFilterCollection (LogicalOperator, SearchFilter[])
Check: HOW TO: Build a complex search using SearchFilter and SearchFilterCollection in EWS Managed API 1.0