I am using C# to get the count of items in Public folders and subfolders, I am using the below code but it does not recognizes the public folder(Earlier I was using the same piece of code to delete items from public folder it worked that time).
Microsoft.Office.Interop.Outlook.Application tempApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.Folder tempInbox = tempApp.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olPublicFoldersAllPublicFolders) as Microsoft.Office.Interop.Outlook.Folder;
if (tempInbox != null) {
if (tempInbox.Folders.Count > 0)....
Please let me know what I am missing. Once the code recognizes the public subfolders I can get the count but it throws the below error.
Error - exception -System.Runtime.InteropServices.COMException (0x8004010F): The attempted operation failed. An object could not be found. at Microsoft.Office.Interop.Outlook.NameSpaceClass.GetDefaultFolder(OlDefaultFolders FolderType)
User contributions licensed under CC BY-SA 3.0