I am using the following code to find all the emails sent from a user, however this only searches the main Inbox folder and doesn't check any sub-folders. I would like to search all the mail items including any sub-folders.
I have tried the WellKnownFolderName.Root
and WellKnownFolderName.Inbox
, and these only search those folders, not the sub-folders.
private static void SearchItems(string email)
{
ItemView iv = new ItemView(10);
FindItemsResults<Item> fiitems = _service.FindItems(WellKnownFolderName.Inbox, "from:[email protected]", iv);
foreach (Item item in fiitems)
{
Console.WriteLine("Subject:" + item.Subject);
Console.WriteLine("Received At:" + item.DateTimeReceived.ToString("dd MMMM yyyy"));
Console.WriteLine();
}
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…