You first need to Find the Folder in order to obtain the FolderId
https://msdn.microsoft.com/en-us/library/office/hh532558(v=exchg.80).aspx . Once you have the FolderId you use the FindItems operation to enumerate the Item within that folder
https://msdn.microsoft.com/en-us/library/office/dn535506(v=exchg.150).aspx eg
Folder SubFolder = FolderFromPath(service, "\\Inbox\\aa", "use@domain.com");
FindItemsResults<Item> FindResults = null;
ItemView itemv = new ItemView(1000);
do
{
FindResults = service.FindItems(SubFolder.Id, itemv);
if (FindResults.Items.Count > 0)
{
foreach (Item itItem in FindResults.Items)
{
Console.WriteLine(itItem.Subject);
}
}
itemv.Offset += FindResults.Items.Count;
} while (FindResults.MoreAvailable);
internal static Folder FolderFromPath(ExchangeService service, String FolderPath, String MailboxName)
{
FolderId RootFolderId = new FolderId(WellKnownFolderName.MsgFolderRoot, MailboxName);
Folder RootFolder = Folder.Bind(service, RootFolderId);
String[] faFldArray = FolderPath.Split('\\');
Folder tfTargetFolder = RootFolder;
for (int lint = 1; lint < faFldArray.Length; lint++)
{
if (faFldArray[lint].Length != 0)
{
FolderView fview = new FolderView(1);
SearchFilter sf = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, faFldArray[lint]);
FindFoldersResults ffResult = service.FindFolders(tfTargetFolder.Id, sf, fview);
if (ffResult.TotalCount == 0)
{
throw new Exception("Folder Not Found");
}
else
{
tfTargetFolder = ffResult.Folders[0];
}
}
}
return tfTargetFolder;
}
Cheers
Glen
-
Marked as answer by
S.P Singh
Tuesday, September 01, 2015 6:14 AM