C# EWS 搜索 SentItems

C# EWS Searching SentItems

我是 C# 的新手,我正在制作一个 *.exe,它必须在我的 Exchange 中搜索具有特定主题的电子邮件。

对于收件箱和其他文件夹,我使用下面的代码(没有问题):

FindFoldersResults allEmailFolders_Inbox = service.FindFolders(WellKnownFolderName.Inbox, new FolderView(int.MaxValue) { Traversal = FolderTraversal.Shallow });
    FindFoldersResults allEmailFolders = service.FindFolders(WellKnownFolderName.Inbox, new FolderView(int.MaxValue) { Traversal = FolderTraversal.Deep });

现在我正在尝试在“已发送项目文件夹”中搜索,但 return 我没有结果。如果我在 SentItems 中创建一个新文件夹,电子邮件 apeears,但在 Sent Items 中没有。我试试下面的代码:

FindFoldersResults allEmailFolders_Sent = service.FindFolders(WellKnownFolderName.SentItems, new FolderView(int.MaxValue){Traversal=FolderTraversal.Deep});

FindFoldersResults allEmailFolders_Sent = service.FindFolders(WellKnownFolderName.SentItems, new FolderView(int.MaxValue){Traversal=FolderTraversal.Shallw});

有人可以帮助我吗?

您显示的代码行正在搜索收件箱或已发送项目文件夹内的文件夹,而不是电子邮件。您可能想查看 MSDN 中的搜索主题:https://msdn.microsoft.com/EN-US/library/office/dn579421(v=exchg.150).aspx. There are links to a number of search samples there as well. This one seems relevant to your scenario: https://code.msdn.microsoft.com/exchange/Exchange-2013-Search-for-2ea5597e/sourcecode?fileId=84155&pathId=889776652