static void DeleteFolder(ExchangeService service, string DisplayName, DeleteMode deleteMode, WellKnownFolderName ParentFolder)
        {
            // Attempt to retrieve the unique identifier of the folder with the specified display name (DisplayName) within the specified folder (ParentFolder).
            FolderId folderId = Ex15_FindFolderIdByDisplayName_CS.FindFolderIdByDisplayName(service, DisplayName, ParentFolder);

            if (folderId != null)
            {
                // Bind to the folder by using its unique identifier.
                Folder folder = Folder.Bind(service, folderId);

                // Delete the folder.
                folder.Delete(deleteMode);

                Console.WriteLine("Folder '" + DisplayName + "' has been deleted.");
            }
            else
            {
                Console.WriteLine("Folder '" + DisplayName + "' could not be found in the '" + ParentFolder + "' folder.");
            }
        }
        static void MoveFolder(ExchangeService service, string DisplayName, WellKnownFolderName SourceFolder, WellKnownFolderName DestinationFolder)
        {
            // Attempt to retrieve the unique identifier of the folder with the specified display name (DisplayName) within the specified folder (SourceFolder).
            FolderId folderId = Ex15_FindFolderIdByDisplayName_CS.FindFolderIdByDisplayName(service, DisplayName, SourceFolder);

            if (folderId != null)
            {
                // Bind to the folder by using its unique identifier.
                Folder folder = Folder.Bind(service, folderId);

                // Move the folder from its current location into the specified location (DestinationFolder).
                Folder newFolder = folder.Move(DestinationFolder);

                Console.WriteLine("Folder '" + DisplayName + "' has been moved to the '" + DestinationFolder.ToString() + "' folder.");
            }
            else
            {
                Console.WriteLine("Folder '" + DisplayName + "' could not be found in the '" + SourceFolder + "' folder.");
            }
        }
Example #3
0
        static void UpdateFolderName(ExchangeService service, string CurrentDisplayName, string NewDisplayName, WellKnownFolderName ParentFolder)
        {
            // Attempt to retrieve the unique identifier of the folder with the specified display name (CurrentDisplayName) within the specified folder (ParentFolder).
            FolderId folderId = Ex15_FindFolderIdByDisplayName_CS.FindFolderIdByDisplayName(service, CurrentDisplayName, ParentFolder);

            if (folderId != null)
            {
                // Bind to the folder by using its unique identifier.
                Folder folder = Folder.Bind(service, folderId);

                // Change the display name of the folder.
                folder.DisplayName = NewDisplayName;

                // Save the change.
                folder.Update();

                Console.WriteLine("Folder name changed from '" + CurrentDisplayName + "' to '" + NewDisplayName + "'.");
            }
            else
            {
                Console.WriteLine("Folder '" + CurrentDisplayName + "' could not be found in the '" + ParentFolder + "' folder.");
            }
        }