How to find if the inbox exists and create if it does not exist

Simple use of Exchange Webservices 1.1 in Exchange 2010. I cannot find an example of how to find specific folders, and if not, create it. How it's done?

+6
source share
1 answer

Well, after several days of classes and research on the net, I realized:

FolderView fv = new FolderView(10); var findFoldersResults = service.FindFolders( WellKnownFolderName.Inbox, new SearchFilter.SearchFilterCollection( LogicalOperator.Or, new SearchFilter.ContainsSubstring(FolderSchema.DisplayName, "ERROR"), new SearchFilter.ContainsSubstring(FolderSchema.DisplayName, "ARCHIVE")), fv); foreach (var folder in findFoldersResults) { if (folder is Folder) { if (folder.DisplayName.ToUpper() == "ARCHIVE") { archiveFolderID = folder.Id; } else if (folder.DisplayName.ToUpper() == "ERROR") { errorFolderID = folder.Id; } } } //if archive folder not found create and assign the variable to the folderID if (archiveFolderID == null) { Folder folder = new Folder(service); folder.DisplayName = "ARCHIVE"; folder.Save(WellKnownFolderName.Inbox); archiveFolderID = folder.Id; } //if error folder not found create and assign the variable to the folderID if (errorFolderID == null) { Folder folder = new Folder(service); folder.DisplayName = "ERROR"; folder.Save(WellKnownFolderName.Inbox); errorFolderID = folder.Id; } 
+13
source

Source: https://habr.com/ru/post/890771/


All Articles