简体   繁体   English

EWS(office 365)创建 Seachfolder 不工作

[英]EWS(office 365) create Seachfolder not working

I have a program that loops all emails in Office 365 using the EWS services and if the match some criteria they get tagged with a category.我有一个程序使用 EWS 服务循环 Office 365 中的所有电子邮件,如果符合某些条件,它们会被标记为一个类别。 I then what to create a seachfolder that looks mails that has the category.然后我创建一个 seachfolder 来查找具有该类别的邮件。

This is my code这是我的代码

SearchFolder searchFolder = new SearchFolder(service);
            SearchFilter filter = new SearchFilter.ContainsSubstring(ItemSchema.Categories, categoryName);
            searchFolder.DisplayName = "Mulige CPR-data";

            searchFolder.SearchParameters.RootFolderIds.Add(WellKnownFolderName.Inbox);
            searchFolder.SearchParameters.Traversal = SearchFolderTraversal.Deep;
            searchFolder.SearchParameters.SearchFilter = filter;

            try
            {
                searchFolder.Save(WellKnownFolderName.SearchFolders);
                Console.WriteLine(searchFolder.DisplayName + " added.");
            }
            catch (Exception e)
            {
                //error handling
            }

The Seachfolder is created but when i access it in Outlook 365 I get a message saying something like "Nothing found" (I have the danish version, so not sure about the english message). Seachfolder 已创建,但是当我在 Outlook 365 中访问它时,我收到一条消息,上面写着“未找到任何东西”(我有丹麦版本,所以不确定英文消息)。

After som trial and error I found that i this instead it works fine经过一番反复试验后,我发现我这样做了,它工作正常

SearchFilter filter = new SearchFilter.ContainsSubstring(ItemSchema.Subject, "subjectTest");

So my question is why are my seachfolder not working when using categories but working fine when checking for something i the subject.所以我的问题是为什么我的 seachfolder 在使用类别时不工作,但在检查主题时工作正常。

Bonus info - If I create a seachfolder in outlook using the same seach criteria(category) it works fine.奖励信息 - 如果我使用相同的搜索标准(类别)在 outlook 中创建一个搜索文件夹,它工作正常。

EWS SearchFilters don't support the logic for querying Multi-valued string properties (while the underlying Store Restriction does which is why it works in Outlook which uses MAPI). EWS SearchFilters 不支持查询多值字符串属性的逻辑(而底层存储限制支持,这就是它在使用 MAPI 的 Outlook 中工作的原因)。 Eg your search filter won't work in a FindItem Request either.例如,您的搜索过滤器在 FindItem 请求中也不起作用。 In the Microsoft Graph it seems they have supported some additional search logic so you can create Search folders that will do a MV Search eg the following would work在 Microsoft Graph 中,他们似乎支持了一些额外的搜索逻辑,因此您可以创建搜索文件夹来执行 MV 搜索,例如以下内容将起作用

 https://graph.microsoft.com/v1.0/me/mailfolders('searchfolders')/childfolders { "@odata.type": "microsoft.graph.mailSearchFolder", "displayName": "Red Items", "includeNestedFolders": true, "sourceFolderIds": [ "AQ.." ], "filterQuery": "categories/any(a:a eq 'Red Category')" }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM