0
votes

I'm new with C# and i'm making one *.exe that have to search emails with a specific subject in my Exchange.

For Inbox and Other Folders i use the code bellow (with no problems):

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 });

Now i'm trying to search inside Sent Item Folder, but don't return me results. If i make a new folder inside SentItems the email apeears, but inside Sent items no. I try the code bellow:

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});

Can someone help me?

1

1 Answers

1
votes

The lines of code you've shown are searching for folders inside the inbox or inside the sent items folder, not email. You might want to take a look at the Search topics in 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